diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-22 09:47:33 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-22 09:47:33 +0200 | 
| commit | 53888c24ca9dc156e5ffa0dc66e1bf36a00085a0 (patch) | |
| tree | f4b6d2c1dd642d37eb786703597f40c69c789119 /archaeological_finds/models.py | |
| parent | 4894a53ebb007d80f2a602147481645358ab4ab7 (diff) | |
| download | Ishtar-53888c24ca9dc156e5ffa0dc66e1bf36a00085a0.tar.bz2 Ishtar-53888c24ca9dc156e5ffa0dc66e1bf36a00085a0.zip | |
Improve cached label regeneration when modifying parent items (refs #3341)
Diffstat (limited to 'archaeological_finds/models.py')
| -rw-r--r-- | archaeological_finds/models.py | 22 | 
1 files changed, 10 insertions, 12 deletions
| diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 016bf4d45..5799d0e9a 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -645,6 +645,7 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):          super(Find, self).save(*args, **kwargs)          updated = False +        self.skip_history_when_saving = True          if not self.external_id or self.auto_external_id:              external_id = get_external_id('find_external_id', self)              if external_id != self.external_id: @@ -678,19 +679,16 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):                  modified = True                  base_find.index = BaseFind.get_max_index(                      base_find.context_record.operation) + 1 -            if not base_find.cache_short_id or \ -                    not base_find.cache_short_id.endswith( -                        unicode(base_find.index)): -                base_find.cache_short_id = base_find.short_id() -                if base_find.cache_short_id: -                    modified = True -            if not base_find.cache_complete_id or \ -                    not base_find.cache_complete_id.endswith( -                        unicode(base_find.index)): -                base_find.cache_complete_id = base_find.complete_id() -                if base_find.cache_complete_id: -                    modified = True +            short_id = base_find.short_id() +            if base_find.cache_short_id != short_id: +                base_find.cache_short_id = short_id +                modified = True +            complete_id = base_find.complete_id() +            if base_find.cache_complete_id != complete_id: +                base_find.cache_complete_id = complete_id +                modified = True              if modified: +                base_find.skip_history_when_saving = True                  base_find.save()              # if not base_find.material_index:              #    idx = BaseFind.objects\ | 
