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 | |
parent | 6b8d331994d4aecb8579423a67d9fd9e497e7d7e (diff) | |
download | Ishtar-1da5669b4e24621d43a1e6c9c7a519e180a9e302.tar.bz2 Ishtar-1da5669b4e24621d43a1e6c9c7a519e180a9e302.zip |
Search vectors for authors and sources
-rw-r--r-- | archaeological_context_records/migrations/0015_contextrecordsource_search_vector.py | 21 | ||||
-rw-r--r-- | archaeological_context_records/models.py | 1 | ||||
-rw-r--r-- | archaeological_finds/migrations/0015_auto_20180119_1516.py | 31 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 1 | ||||
-rw-r--r-- | archaeological_finds/models_treatments.py | 2 | ||||
-rw-r--r-- | archaeological_operations/migrations/0014_operationsource_search_vector.py | 21 | ||||
-rw-r--r-- | archaeological_operations/models.py | 2 | ||||
-rw-r--r-- | ishtar_common/migrations/0026_auto_20180119_1516.py | 41 | ||||
-rw-r--r-- | ishtar_common/models.py | 26 |
9 files changed, 140 insertions, 6 deletions
diff --git a/archaeological_context_records/migrations/0015_contextrecordsource_search_vector.py b/archaeological_context_records/migrations/0015_contextrecordsource_search_vector.py new file mode 100644 index 000000000..0b7a9ae30 --- /dev/null +++ b/archaeological_context_records/migrations/0015_contextrecordsource_search_vector.py @@ -0,0 +1,21 @@ +# -*- 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 + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_context_records', '0014_contextrecord_images'), + ] + + operations = [ + migrations.AddField( + model_name='contextrecordsource', + name='search_vector', + field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'), + ), + ] diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index dde661ee7..71e8330b7 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -670,6 +670,7 @@ class ContextRecordSource(Source): 'context_record__datings__period__pk', 'context_record__unit': 'context_record__unit__pk', } + PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['context_record'] class Meta: verbose_name = _(u"Context record documentation") diff --git a/archaeological_finds/migrations/0015_auto_20180119_1516.py b/archaeological_finds/migrations/0015_auto_20180119_1516.py new file mode 100644 index 000000000..7d2067771 --- /dev/null +++ b/archaeological_finds/migrations/0015_auto_20180119_1516.py @@ -0,0 +1,31 @@ +# -*- 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 + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_finds', '0014_auto_20171110_1717'), + ] + + operations = [ + migrations.AddField( + model_name='findsource', + name='search_vector', + field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'), + ), + migrations.AddField( + model_name='treatmentfilesource', + name='search_vector', + field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'), + ), + migrations.AddField( + model_name='treatmentsource', + name='search_vector', + field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'), + ), + ] diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 2b782c614..e1c866f9d 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1361,6 +1361,7 @@ class FindSource(Source): 'find__datings__period': 'find__datings__period__pk', 'find__description': 'find__description__icontains', } + PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['find'] class Meta: verbose_name = _(u"Find documentation") diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 6c173959a..38d4f55b3 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -594,6 +594,7 @@ class TreatmentSource(Source): TABLE_COLS = ['treatment__cached_label'] + Source.TABLE_COLS COL_LABELS = {'treatment__cached_label': _(u"Treatment")} SHOW_URL = 'show-treatmentsource' + PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['treatment'] class Meta: verbose_name = _(u"Treatment documentation") @@ -628,6 +629,7 @@ class TreatmentFileSource(Source): TABLE_COLS = ['treatment_file__cached_label'] + Source.TABLE_COLS COL_LABELS = {'treatment_file__cached_label': _(u"Treatment file")} SHOW_URL = 'show-treatmentfilesource' + PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['treatment_file'] class Meta: verbose_name = _(u"Treatment request documentation") diff --git a/archaeological_operations/migrations/0014_operationsource_search_vector.py b/archaeological_operations/migrations/0014_operationsource_search_vector.py new file mode 100644 index 000000000..ceac0785f --- /dev/null +++ b/archaeological_operations/migrations/0014_operationsource_search_vector.py @@ -0,0 +1,21 @@ +# -*- 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 + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_operations', '0013_operation_images'), + ] + + operations = [ + migrations.AddField( + model_name='operationsource', + name='search_vector', + field=django.contrib.postgres.search.SearchVectorField(blank=True, help_text='Auto filled at save', null=True, verbose_name='Search vector'), + ), + ] diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 2f1ea3ea3..5c3b91e9f 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -924,6 +924,8 @@ class OperationSource(Source): 'operation__operation_code': _(u"Operation code"), 'code': _(u"Document code") } + PARENT_SEARCH_VECTORS = Source.PARENT_SEARCH_VECTORS + ['operation'] + # fields operation = models.ForeignKey(Operation, verbose_name=_(u"Operation"), 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 |