diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-19 15:35:43 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-19 15:35:43 +0100 |
commit | 1da5669b4e24621d43a1e6c9c7a519e180a9e302 (patch) | |
tree | b3aa5c0104016c4fb84f656f051ce0206e61a5f1 /ishtar_common | |
parent | 6b8d331994d4aecb8579423a67d9fd9e497e7d7e (diff) | |
download | Ishtar-1da5669b4e24621d43a1e6c9c7a519e180a9e302.tar.bz2 Ishtar-1da5669b4e24621d43a1e6c9c7a519e180a9e302.zip |
Search vectors for authors and sources
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/migrations/0026_auto_20180119_1516.py | 41 | ||||
-rw-r--r-- | ishtar_common/models.py | 26 |
2 files changed, 61 insertions, 6 deletions
diff --git a/ishtar_common/migrations/0026_auto_20180119_1516.py b/ishtar_common/migrations/0026_auto_20180119_1516.py new file mode 100644 index 000000000..039d8752f --- /dev/null +++ b/ishtar_common/migrations/0026_auto_20180119_1516.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2018-01-19 15:16 +from __future__ import unicode_literals + +import django.contrib.postgres.search +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0025_ishtaruser_search_vector'), + ] + + operations = [ + migrations.AddField( + model_name='author', + name='search_vector', + field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'), + ), + migrations.AlterField( + model_name='jsondatafield', + name='key', + field=models.CharField(help_text='Value of the key in the JSON schema. For hierarchical key use "__" to explain it. For instance for the key \'my_subkey\' with data such as {\'my_key\': {\'my_subkey\': \'value\'}}, its value will be reached with my_key__my_subkey.', max_length=200, verbose_name='Key'), + ), + migrations.AlterField( + model_name='targetkeygroup', + name='all_user_can_modify', + field=models.BooleanField(default=False, verbose_name='All users can modify it'), + ), + migrations.AlterField( + model_name='targetkeygroup', + name='all_user_can_use', + field=models.BooleanField(default=False, verbose_name='All users can use it'), + ), + migrations.AlterField( + model_name='town', + name='year', + field=models.IntegerField(blank=True, help_text='Filling this field is relevant to distinguish old towns from new towns.', null=True, verbose_name='Year of creation'), + ), + ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 4f500db60..66b15be34 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2246,7 +2246,7 @@ class Organization(Address, Merge, OwnPerms, ValueGetter): 'name': 'name__icontains', 'organization_type': 'organization_type__pk__in', } - BASE_SEARCH_VECTORS = ['name', 'town__name'] + BASE_SEARCH_VECTORS = ['name', 'town'] # fields name = models.CharField(_(u"Name"), max_length=500) @@ -2304,6 +2304,8 @@ class PersonType(GeneralType): verbose_name = _(u"Person type") verbose_name_plural = _(u"Person types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=PersonType) post_delete.connect(post_save_cache, sender=PersonType) @@ -2316,6 +2318,8 @@ class TitleType(GeneralType): verbose_name = _(u"Title type") verbose_name_plural = _(u"Title types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=TitleType) post_delete.connect(post_save_cache, sender=TitleType) @@ -2333,7 +2337,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter): 'attached_to__name', 'town') SHOW_URL = 'show-person' MODIFY_URL = 'person_modify' - BASE_SEARCH_VECTORS = ['name', 'surname', 'raw_name', 'town__name', + BASE_SEARCH_VECTORS = ['name', 'surname', 'raw_name', 'town', 'attached_to__name', 'email'] # search parameters @@ -2554,8 +2558,8 @@ class IshtarUser(FullSearch): 'person__email', 'person__person_types_list', 'person__attached_to') BASE_SEARCH_VECTORS = [ - 'username', 'person__name', 'person__surname', 'person__email', - 'person__town__name', 'person__attached_to__name'] + 'user_ptr__username', 'person__name', 'person__surname', + 'person__email', 'person__town', 'person__attached_to__name'] # search parameters EXTRA_REQUEST_KEYS = { @@ -2675,10 +2679,11 @@ post_save.connect(post_save_cache, sender=AuthorType) post_delete.connect(post_save_cache, sender=AuthorType) -class Author(models.Model): +class Author(FullSearch): person = models.ForeignKey(Person, verbose_name=_(u"Person"), related_name='author') author_type = models.ForeignKey(AuthorType, verbose_name=_(u"Author type")) + PARENT_SEARCH_VECTORS = ['person'] class Meta: verbose_name = _(u"Author") @@ -2712,6 +2717,8 @@ class SourceType(GeneralType): verbose_name = _(u"Source type") verbose_name_plural = _(u"Source types") ordering = ['label'] + + post_save.connect(post_save_cache, sender=SourceType) post_delete.connect(post_save_cache, sender=SourceType) @@ -2720,6 +2727,8 @@ class SupportType(GeneralType): class Meta: verbose_name = _(u"Support type") verbose_name_plural = _(u"Support types") + + post_save.connect(post_save_cache, sender=SupportType) post_delete.connect(post_save_cache, sender=SupportType) @@ -2735,7 +2744,7 @@ post_save.connect(post_save_cache, sender=Format) post_delete.connect(post_save_cache, sender=Format) -class Source(OwnPerms, ImageModel, models.Model): +class Source(OwnPerms, ImageModel, FullSearch): title = models.CharField(_(u"Title"), max_length=300) external_id = models.TextField(_(u"External ID"), max_length=300, null=True, blank=True) @@ -2768,8 +2777,13 @@ class Source(OwnPerms, ImageModel, models.Model): additional_information = models.TextField(_(u"Additional information"), blank=True, null=True) duplicate = models.BooleanField(_(u"Has a duplicate"), default=False) + TABLE_COLS = ['title', 'source_type', 'authors', 'associated_url'] COL_LINK = ['associated_url'] + BASE_SEARCH_VECTORS = ['title', 'source_type__label', 'external_id', + 'reference', 'description', 'comment', + 'additional_information'] + PARENT_SEARCH_VECTORS = ['authors'] class Meta: abstract = True |