diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 483e15786..07a052470 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -62,7 +62,7 @@ from django.db.utils import DatabaseError from django.template.defaultfilters import slugify from django.utils.functional import lazy from ishtar_common.utils import ugettext_lazy as _, ugettext, \ - pgettext_lazy, get_external_id, get_current_profile, duplicate_item, \ + pgettext_lazy, get_generated_id, get_current_profile, duplicate_item, \ get_image_path from ishtar_common.utils_secretary import IshtarSecretaryRenderer @@ -87,21 +87,22 @@ from ishtar_common.models_common import GeneralType, HierarchicalType, \ FixAssociated, SearchAltName, HistoryError, OwnPerms, Cached, \ Address, post_save_cache, TemplateItem, SpatialReferenceSystem, \ DashboardFormItem, document_attached_changed, SearchAltName, \ - DynamicRequest, GeoItem, QRCodeItem, SearchVectorConfig, DocumentItem, \ - QuickAction, MainItem, Merge, ShortMenuItem, Town, ImageContainerModel, \ - StatisticItem, CachedGen, CascasdeUpdate, Department, State + DynamicRequest, GeoItem, CompleteIdentifierItem, SearchVectorConfig, \ + DocumentItem, QuickAction, MainItem, Merge, ShortMenuItem, Town, \ + ImageContainerModel, StatisticItem, CachedGen, CascasdeUpdate, \ + Department, State __all__ = [ 'ImporterModel', 'ImporterType', 'ImporterDefault', 'ImporterDefaultValues', 'ImporterColumn', 'ImporterDuplicateField', 'Regexp', 'ImportTarget', 'TargetKey', 'FormaterType', 'Import', 'TargetKeyGroup', 'ValueFormater', 'Organization', 'Person', 'valid_id', 'Town', 'SpatialReferenceSystem', - 'OrganizationType', 'Document', 'GeneralType', 'get_external_id', + 'OrganizationType', 'Document', 'GeneralType', 'get_generated_id', 'LightHistorizedItem', 'OwnPerms', 'Address', 'post_save_cache', 'DashboardFormItem', 'ShortMenuItem', 'document_attached_changed', - 'SearchAltName', 'DynamicRequest', 'GeoItem', 'QRCodeItem', + 'SearchAltName', 'DynamicRequest', 'GeoItem', 'SearchVectorConfig', 'DocumentItem', 'CachedGen', 'StatisticItem', - 'CascasdeUpdate', 'Department', 'State' + 'CascasdeUpdate', 'Department', 'State', 'CompleteIdentifierItem' ] logger = logging.getLogger(__name__) @@ -816,6 +817,15 @@ class IshtarSiteProfile(models.Model, Cached): _("Operation region code"), null=True, blank=True, max_length=5 ) + operation_complete_identifier = models.TextField( + _("Operation complete identifier"), + default="", + help_text=_("Formula to manage operation complete identifier.")) + site_complete_identifier = models.TextField( + _("Archaeological site complete identifier"), + default="", + help_text=_("Formula to manage archaeological site complete" + " identifier.")) file_external_id = models.TextField( _("File external id"), default="{year}-{numeric_reference}", @@ -823,6 +833,11 @@ class IshtarSiteProfile(models.Model, Cached): "Change this with care. With incorrect formula, the " "application might be unusable and import of external " "data can be destructive.")) + file_complete_identifier = models.TextField( + _("Archaeological file complete identifier"), + default="", + help_text=_("Formula to manage archaeological file complete " + "identifier.")) parcel_external_id = models.TextField( _("Parcel external id"), default="{associated_file__external_id}{operation__code_patriarche}-" @@ -838,6 +853,10 @@ class IshtarSiteProfile(models.Model, Cached): "Change this with care. With incorrect formula, the " "application might be unusable and import of external " "data can be destructive.")) + context_record_complete_identifier = models.TextField( + _("Context record complete identifier"), + default="", + help_text=_("Formula to manage context record complete identifier.")) base_find_external_id = models.TextField( _("Base find external id"), default="{context_record__external_id}-{label}", @@ -845,6 +864,10 @@ class IshtarSiteProfile(models.Model, Cached): "Change this with care. With incorrect formula, the " "application might be unusable and import of external " "data can be destructive.")) + basefind_complete_identifier = models.TextField( + _("Base find complete identifier"), + default="", + help_text=_("Formula to manage base find complete identifier.")) find_external_id = models.TextField( _("Find external id"), default="{get_first_base_find__context_record__external_id}-{label}", @@ -852,6 +875,10 @@ class IshtarSiteProfile(models.Model, Cached): "Change this with care. With incorrect formula, the " "application might be unusable and import of external " "data can be destructive.")) + find_complete_identifier = models.TextField( + _("Find complete identifier"), + default="", + help_text=_("Formula to manage find complete identifier.")) container_external_id = models.TextField( _("Container external id"), default="{parent_external_id}-{container_type__txt_idx}-" @@ -860,6 +887,10 @@ class IshtarSiteProfile(models.Model, Cached): "Change this with care. With incorrect formula, the " "application might be unusable and import of external " "data can be destructive.")) + container_complete_identifier = models.TextField( + _("Container complete identifier"), + default="", + help_text=_("Formula to manage container complete identifier.")) warehouse_external_id = models.TextField( _("Warehouse external id"), default="{name|slug}", @@ -867,6 +898,10 @@ class IshtarSiteProfile(models.Model, Cached): "Change this with care. With incorrect formula, the " "application might be unusable and import of external " "data can be destructive.")) + warehouse_complete_identifier = models.TextField( + _("Warehouse complete identifier"), + default="", + help_text=_("Formula to manage warehouse complete identifier.")) document_external_id = models.TextField( _("Document external id"), default="{index}", @@ -874,6 +909,10 @@ class IshtarSiteProfile(models.Model, Cached): "Change this with care. With incorrect formula, the " "application might be unusable and import of external " "data can be destructive.")) + document_complete_identifier = models.TextField( + _("Document complete identifier"), + default="", + help_text=_("Formula to manage document complete identifier.")) person_raw_name = models.TextField( _("Raw name for person"), default="{name|upper} {surname}", @@ -1902,7 +1941,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter, MainItem): return self.cached_label or "" def _generate_cached_label(self): - lbl = get_external_id('person_raw_name', self) + lbl = get_generated_id('person_raw_name', self) if not lbl: return "-" if self.attached_to: @@ -2044,7 +2083,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter, MainItem): def save(self, *args, **kwargs): super(Person, self).save(*args, **kwargs) - raw_name = get_external_id('person_raw_name', self) + raw_name = get_generated_id('person_raw_name', self) if raw_name and self.raw_name != raw_name: self.raw_name = raw_name self.save() @@ -2581,7 +2620,7 @@ post_save.connect(post_save_cache, sender=LicenseType) post_delete.connect(post_save_cache, sender=LicenseType) -class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel, +class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel, ValueGetter, MainItem): APP = "ishtar-common" MODEL = "document" |