diff options
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 14 | 
1 files changed, 13 insertions, 1 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index a03f9f387..93a099b74 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -87,7 +87,7 @@ from ishtar_common.models_imports import ImporterModel, ImporterType, \      Import, TargetKeyGroup, ValueFormater  from ishtar_common.templatetags.link_to_window import simple_link_to_window  from ishtar_common.utils import get_cache, disable_for_loaddata, create_slug, \ -    get_all_field_names, merge_tsvectors, cached_label_changed, \ +    get_all_field_names, merge_tsvectors, cached_label_changed, post_save_geo, \      generate_relation_graph, max_size_help, task, SecretaryRenderer  __all__ = [ @@ -1963,6 +1963,7 @@ class BaseHistorizedItem(StatisticItem, TemplateItem, FullSearch, Imported,      SHOW_URL = None      EXTERNAL_ID_KEY = ''      EXTERNAL_ID_DEPENDENCIES = [] +    DOWN_MODEL_UPDATE = []      HISTORICAL_M2M = []      history_modifier = models.ForeignKey( @@ -1973,6 +1974,8 @@ class BaseHistorizedItem(StatisticItem, TemplateItem, FullSearch, Imported,          verbose_name=_("Creator"), blank=True, null=True)      last_modified = models.DateTimeField(auto_now=True)      history_m2m = JSONField(default={}, blank=True) +    need_update = models.BooleanField( +        verbose_name=_("Need update"), default=False)      ALT_NAMES = {          'history_creator': SearchAltName( @@ -1992,6 +1995,15 @@ class BaseHistorizedItem(StatisticItem, TemplateItem, FullSearch, Imported,      class Meta:          abstract = True +    def cascade_update(self): +        for down_model in self.DOWN_MODEL_UPDATE: +            if not settings.USE_BACKGROUND_TASK: +                getattr(self, down_model).update(need_update=True) +                continue +            for item in getattr(self, down_model).all(): +                cached_label_changed(item.model, instance=item) +                post_save_geo(item.model, instance=item) +      @classmethod      def get_verbose_name(cls):          return cls._meta.verbose_name  | 
