diff options
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 33 | 
1 files changed, 18 insertions, 15 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index e7f0e9262..946e88703 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2103,8 +2103,24 @@ class StatisticItem:      )  # example: "Price", "Volume" - the number is a multiplier +class CascasdeUpdate: +    DOWN_MODEL_UPDATE = [] + +    def cascade_update(self): +        for down_model in self.DOWN_MODEL_UPDATE: +            if not settings.USE_BACKGROUND_TASK: +                rel = getattr(self, down_model) +                if hasattr(rel.model, "need_update"): +                    rel.update(need_update=True) +                    continue +            for item in getattr(self, down_model).all(): +                cached_label_changed(item.__class__, instance=item) +                if hasattr(item, "point_2d"): +                    post_save_geo(item.__class__, instance=item) + +  class BaseHistorizedItem(StatisticItem, TemplateItem, FullSearch, Imported, -                         JsonData, FixAssociated): +                         JsonData, FixAssociated, CascasdeUpdate):      """      Historized item with external ID management.      All historized items are searchable and have a data json field. @@ -2114,7 +2130,6 @@ class BaseHistorizedItem(StatisticItem, TemplateItem, FullSearch, Imported,      SHOW_URL = None      EXTERNAL_ID_KEY = ''      EXTERNAL_ID_DEPENDENCIES = [] -    DOWN_MODEL_UPDATE = []      HISTORICAL_M2M = []      history_modifier = models.ForeignKey( @@ -2151,18 +2166,6 @@ 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: -                rel = getattr(self, down_model) -                if hasattr(rel.model, "need_update"): -                    rel.update(need_update=True) -                    continue -            for item in getattr(self, down_model).all(): -                cached_label_changed(item.__class__, instance=item) -                if hasattr(item, "point_2d"): -                    post_save_geo(item.__class__, instance=item) -      @classmethod      def get_verbose_name(cls):          return cls._meta.verbose_name @@ -4875,8 +4878,8 @@ post_delete.connect(post_save_cache, sender=AuthorType)  class Author(FullSearch): -    PARENT_SEARCH_VECTORS = ['person']      SLUG = "author" +    PARENT_SEARCH_VECTORS = ['person']      uuid = models.UUIDField(default=uuid.uuid4)      person = models.ForeignKey(Person, verbose_name=_("Person"), | 
