diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-10 17:59:44 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:04 +0200 | 
| commit | 6fd955966b18bb138219eae151dec3b29f2685ee (patch) | |
| tree | 04f21ad44a463b7e9677f56f9243b7e5de228811 /archaeological_context_records/models.py | |
| parent | 36b3cc6849ef3eff539d3242246a2b6aba6e5cba (diff) | |
| download | Ishtar-6fd955966b18bb138219eae151dec3b29f2685ee.tar.bz2 Ishtar-6fd955966b18bb138219eae151dec3b29f2685ee.zip | |
Context record search configuration
Diffstat (limited to 'archaeological_context_records/models.py')
| -rw-r--r-- | archaeological_context_records/models.py | 57 | 
1 files changed, 55 insertions, 2 deletions
| diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 211be9ade..97bf2a117 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -25,10 +25,10 @@ from django.core.urlresolvers import reverse  from django.db import connection, transaction  from django.db.models import Q  from django.db.models.signals import post_delete, post_save -from django.utils.translation import ugettext_lazy as _, ugettext, pgettext +from django.utils.translation import ugettext_lazy as _, pgettext, pgettext_lazy  from django.utils.text import slugify -from ishtar_common.utils import cached_label_changed +from ishtar_common.utils import cached_label_changed, TXT_SEARCH_COMMENT  from ishtar_common.models import Document, GeneralType, \      BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \ @@ -256,6 +256,55 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,      RELATIVE_SESSION_NAMES = [          ('operation', 'operation__pk'),          ('file', 'operation__associated_file__pk')] +    # alternative names of fields for searches +    ALT_NAMES = { +        'label': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"id"), +            'label' +        ), +        'town': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"town"), +            'town__cached_label__iexact' +        ), +        'operation__year': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-year"), +            'operation__year' +        ), +        'operation__code_patriarche': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"patriarche"), +            'operation__code_patriarche' +        ), +        'operation__operation_code': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-code"), +            'operation__operation_code' +        ), +        'archaeological_site': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"site"), +            'archaeological_site__cached_label__icontains' +        ), +        'ope_relation_types': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-relation-type"), +            'ope_relation_types' +        ), +        'datings__period': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"period"), +            'datings__period__label__iexact' +        ), +        'unit': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"unit-type"), +            'unit__label__iexact' +        ), +        'parcel': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"parcel"), +            'parcel__cached_label__iexact' +        ), +        'cr_relation_types': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"record-relation-type"), +            'cr_relation_types' +        ), +    } +    for v in ALT_NAMES.values(): +        EXTRA_REQUEST_KEYS[v[0]] = v[1]      # fields      external_id = models.TextField(_(u"External ID"), blank=True, null=True) @@ -670,5 +719,9 @@ class RecordRelationView(models.Model):              ("view_recordrelation", u"Can view all record relations - view"),          ] +    @classmethod +    def general_types(cls): +        return [] +      def __unicode__(self):          return u"{} \"{}\"".format(self.relation_type, self.right_record) | 
