diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-21 20:28:02 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-01-21 20:28:02 +0100 |
commit | 8661870960701ba1ac7b52a867ed14d10acacf93 (patch) | |
tree | 5e230e6e9a775029ee560a92a4678064ae1a3ec4 /archaeological_operations/models.py | |
parent | 9aa59d8ea96e19d472227ff6eefdefc929523700 (diff) | |
download | Ishtar-8661870960701ba1ac7b52a867ed14d10acacf93.tar.bz2 Ishtar-8661870960701ba1ac7b52a867ed14d10acacf93.zip |
Administrativ act: adapt forms, models and sheet
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 58fa8b8c6..d46d55089 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -986,6 +986,8 @@ class ActType(GeneralType): verbose_name = _(u"Act type") verbose_name_plural = _(u"Act types") ordering = ('label',) + + post_save.connect(post_save_cache, sender=ActType) post_delete.connect(post_save_cache, sender=ActType) @@ -1051,6 +1053,12 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): RELATIVE_SESSION_NAMES = [('operation', 'operation__pk'), ('file', 'associated_file__pk')] COL_LABELS = {'full_ref': _(u"Ref.")} + BASE_SEARCH_VECTORS = ['act_type__label', 'act_object', + 'towns_label'] + INT_SEARCH_VECTORS = ["year", "index"] + PARENT_SEARCH_VECTORS = ['operator', 'scientist', 'signatory', + 'associated_file', 'operation', 'treatment_file', + 'treatment'] # fields act_type = models.ForeignKey(ActType, verbose_name=_(u"Act type")) @@ -1248,25 +1256,23 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): if 'force' in kwargs: force = kwargs.pop('force') - if not self.signature_date: - return super(AdministrativeAct, self).save(*args, **kwargs) - self.year = self.signature_date.year - - if not self.act_type.indexed: - return super(AdministrativeAct, self).save(*args, **kwargs) - - if not force: - self._get_index() - else: - try: - self._get_index() - except: - pass - + if self.signature_date: + self.year = self.signature_date.year + if self.act_type.indexed: + if not force: + self._get_index() + else: + try: + self._get_index() + except: + pass super(AdministrativeAct, self).save(*args, **kwargs) if hasattr(self, 'associated_file') and self.associated_file: self.associated_file.update_has_admin_act() self.associated_file.update_short_menu_class() + updated = self.update_search_vector() + if updated: + self.save() def strip_zero(value): |