diff options
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): |