diff options
Diffstat (limited to 'archaeological_finds/models_finds.py')
-rw-r--r-- | archaeological_finds/models_finds.py | 128 |
1 files changed, 126 insertions, 2 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 1ebfb6a15..322cf90e4 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -27,10 +27,11 @@ from django.db.models import Max, Q from django.db.models.signals import m2m_changed, post_save, post_delete, \ pre_delete from django.core.exceptions import ObjectDoesNotExist -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, pgettext_lazy from ishtar_common.data_importer import post_importer_action, ImporterError -from ishtar_common.utils import cached_label_changed, post_save_point +from ishtar_common.utils import cached_label_changed, post_save_point, \ + TXT_SEARCH_COMMENT from ishtar_common.models import Document, GeneralType, \ HierarchicalType, BaseHistorizedItem, ShortMenuItem, LightHistorizedItem, \ @@ -211,6 +212,17 @@ post_save.connect(post_save_cache, sender=CommunicabilityType) post_delete.connect(post_save_cache, sender=CommunicabilityType) +class CheckedType(GeneralType): + class Meta: + verbose_name = _(u"Checked type") + verbose_name_plural = _(u"Checked types") + ordering = ('label',) + + +post_save.connect(post_save_cache, sender=CheckedType) +post_delete.connect(post_save_cache, sender=CheckedType) + + class BFBulkView(object): CREATE_SQL = """ CREATE VIEW basefind_cached_bulk_update @@ -713,6 +725,116 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, if key not in EXTRA_REQUEST_KEYS] ) ) + # alternative names of fields for searches + ALT_NAMES = { + 'base_finds__cache_short_id': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"short-id"), + 'base_finds__cache_short_id__iexact' + ), + 'base_finds__cache_complete_id': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"complete-id"), + 'base_finds__cache_complete_id__iexact' + ), + 'label': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"free-id"), + 'label__iexact' + ), + 'denomination': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"denomination"), + 'denomination__icontains' + ), + 'base_finds__context_record__town': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"town"), + 'base_finds__context_record__town__cached_label__iexact' + ), + 'base_finds__context_record__operation__year': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"year"), + 'base_finds__context_record__operation__year' + ), + 'base_finds__context_record__operation__operation_code': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-code"), + 'base_finds__context_record__operation__operation_code' + ), + 'base_finds__context_record__operation__code_patriarche': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"code-patriarche"), + 'base_finds__context_record__operation__code_patriarche' + ), + 'base_finds__context_record__operation__operation_type': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-type"), + 'base_finds__context_record__operation__operation_type' + '__label__iexact' + ), + 'base_finds__context_record__town__areas': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"area"), + 'base_finds__context_record__town__areas__label__iexact', + ), + 'archaeological_sites': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"site"), + 'base_finds__context_record__operation__archaeological_sites__' + 'cached_label__icontains', + ), + 'archaeological_sites_context_record': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"context-record-site"), + 'base_finds__context_record__archaeological_site__' + 'cached_label__icontains', + ), + 'base_finds__context_record': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"context-record"), + 'base_finds__context_record__cached_label__icontains', + ), + 'ope_relation_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-relation-type"), + 'ope_relation_types' + ), + 'cr_relation_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"context-record-relation-type"), + 'cr_relation_types' + ), + 'datings__period': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"period"), + 'datings__period__label__iexact', + ), + 'material_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"material"), + 'material_types__label__iexact', + ), + 'object_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"object-type"), + 'object_types__label__iexact', + ), + 'preservation_to_considers': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"preservation"), + 'preservation_to_considers__label__iexact', + ), + 'conservatory_state': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"conservatory"), + 'conservatory_state__label__iexact', + ), + 'integrities': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"integrity"), + 'integrities__label__iexact', + ), + 'remarkabilities': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"remarkability"), + 'remarkabilities__label__iexact', + ), + 'base_finds__find__description': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"description"), + 'base_finds__find__description__icontains', + ), + 'base_finds__batch': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"batch"), + 'base_finds__batch__label__iexact', + ), + 'checked': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"checked"), + 'checked_type__label__iexact', + ), + + + } + for v in ALT_NAMES.values(): + EXTRA_REQUEST_KEYS[v[0]] = v[1] # fields base_finds = models.ManyToManyField(BaseFind, verbose_name=_(u"Base find"), @@ -801,6 +923,8 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, null=True) previous_id = models.TextField(_(u"Previous ID"), blank=True, null=True) index = models.IntegerField(u"Index", default=0) + checked_type = models.ForeignKey(CheckedType, verbose_name=_(u"Check"), + blank=True, null=True) checked = models.CharField(_(u"Check"), max_length=2, default=u'NC', choices=CHECK_CHOICES) check_date = models.DateField(_(u"Check date"), |