R src/wiki/migrations/0004_article_inherited_from.py => src/wiki/migrations/0003_article_inherited_from.py +1 -1
@@ 7,7 7,7 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
- ('wiki', '0003_article_search_vector'),
+ ('wiki', '0002_auto_20191213_0603'),
]
operations = [
D src/wiki/migrations/0003_article_search_vector.py => src/wiki/migrations/0003_article_search_vector.py +0 -19
@@ 1,19 0,0 @@
-# Generated by Django 2.2.10 on 2020-04-30 20:47
-
-import django.contrib.postgres.search
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('wiki', '0002_auto_20191213_0603'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='article',
- name='search_vector',
- field=django.contrib.postgres.search.SearchVectorField(null=True),
- ),
- ]
A src/wiki/migrations/0004_auto_20200521_0950.py => src/wiki/migrations/0004_auto_20200521_0950.py +28 -0
@@ 0,0 1,28 @@
+# Generated by Django 2.2.12 on 2020-05-21 16:50
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('wiki', '0003_article_inherited_from'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='urlpath',
+ name='level',
+ field=models.PositiveIntegerField(db_index=True, editable=False),
+ ),
+ migrations.AlterField(
+ model_name='urlpath',
+ name='lft',
+ field=models.PositiveIntegerField(db_index=True, editable=False),
+ ),
+ migrations.AlterField(
+ model_name='urlpath',
+ name='rght',
+ field=models.PositiveIntegerField(db_index=True, editable=False),
+ ),
+ ]
M src/wiki/models/article.py => src/wiki/models/article.py +0 -21
@@ 1,7 1,6 @@
from django.conf import settings as django_settings
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
-from django.contrib.postgres.search import SearchVector, SearchVectorField
from django.core.cache import cache
from django.db import models, transaction
from django.db.models import OuterRef, Subquery
@@ 75,8 74,6 @@ class Article(models.Model):
'grinch.Organization', related_name='articles',
null=True, blank=True, on_delete=models.CASCADE)
- search_vector = SearchVectorField(null=True)
-
inherited_from = models.ForeignKey(
'self', related_name='inherit_children',
null=True, blank=True, on_delete=models.SET_NULL,
@@ 108,24 105,6 @@ class Article(models.Model):
for obj in self.articleforobject_set.filter(is_mptt=True):
yield from obj.content_object.get_descendants()
- @transaction.atomic
- def update_search_vector(self):
- Article.objects.annotate(
- wiki_title=Subquery(
- Article.objects.filter(id=OuterRef('id')).values(
- 'current_revision__title'
- )
- ),
- wiki_body=Subquery(
- Article.objects.filter(id=OuterRef('id')).values(
- 'current_revision__content'
- )
- ),
- ).filter(id=self.id).update(
- search_vector=SearchVector('wiki_title', weight='A')
- + SearchVector('wiki_body', weight='B')
- )
-
def get_children(self, max_num=None, user_can_read=None, **kwargs):
"""NB! This generator is expensive, so use it with care!!"""
cnt = 0