diff options
| -rw-r--r-- | archaeological_finds/models.py | 1 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 14 | 
2 files changed, 15 insertions, 0 deletions
| diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 0ef1dab58..e4a247941 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -278,6 +278,7 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):          'base_finds.special_interest': _(u"Base find - Special interest"),          'base_finds.discovery_date': _(u"Base find - Discovery date"),      } +    ATTRS_EQUIV = {'get_first_base_find': 'base_finds'}      base_finds = models.ManyToManyField(BaseFind, verbose_name=_(u"Base find"),                                          related_name='find')      external_id = models.CharField(_(u"External ID"), blank=True, null=True, diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 45b46eb63..908a84a46 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -432,7 +432,21 @@ class Wizard(NamedUrlWizardView):              obj.save()          else:              adds = {} +            # manage attributes relations +            if hasattr(self.model, 'ATTRS_EQUIV'): +                for k in other_objs: +                    if k in self.model.ATTRS_EQUIV: +                        new_k = self.model.ATTRS_EQUIV[k] +                        if new_k in other_objs: +                            other_objs[new_k].update( +                                other_objs[k]) +                        else: +                            other_objs[new_k] = \ +                                other_objs[k].copy()              for dependant_item in other_objs: +                if hasattr(self.model, 'ATTRS_EQUIV') and \ +                        dependant_item in self.model.ATTRS_EQUIV: +                    continue                  m = getattr(self.model, dependant_item)                  if callable(m):                      m = m() | 
