~netlandish/django-wiki

b37d44c2720d4574f51754987dba9938be3bfb75 — Oscar Cortez 4 years ago 95e8995
Add search vector fields
2 files changed, 22 insertions(+), 0 deletions(-)

A src/wiki/migrations/0003_article_search_vector.py
M src/wiki/models/article.py
A src/wiki/migrations/0003_article_search_vector.py => src/wiki/migrations/0003_article_search_vector.py +19 -0
@@ 0,0 1,19 @@
# 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),
        ),
    ]

M src/wiki/models/article.py => src/wiki/models/article.py +3 -0
@@ 1,6 1,7 @@
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 SearchVectorField
from django.core.cache import cache
from django.db import models
from django.db.models.fields import GenericIPAddressField as IPAddressField


@@ 73,6 74,8 @@ class Article(models.Model):
        'grinch.Organization', related_name='articles',
        null=True, blank=True, on_delete=models.CASCADE)

    search_vector = SearchVectorField(null=True)

    # PERMISSIONS
    def can_read(self, user):
        return permissions.can_read(self, user)