diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-11-26 19:02:08 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-11-26 19:02:08 +0100 | 
| commit | 28a6384b57edbbe5b5326637d3eb5b9292f2429e (patch) | |
| tree | f028fad6eb36cbf2a7548941f8c40f0cc834c8f4 | |
| parent | 0895d18fd52514f346a7de75f015953b3f9a3657 (diff) | |
| download | Ishtar-28a6384b57edbbe5b5326637d3eb5b9292f2429e.tar.bz2 Ishtar-28a6384b57edbbe5b5326637d3eb5b9292f2429e.zip | |
Wizard: allow callable to be keys
| -rw-r--r-- | ishtar_common/wizards.py | 6 | 
1 files changed, 5 insertions, 1 deletions
| diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 21cfa6ceb..180ed4618 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -408,6 +408,8 @@ class Wizard(NamedUrlWizardView):                  return self.render(form_list[-1])              for dependant_item in other_objs:                  c_item = getattr(obj, dependant_item) +                if callable(c_item): +                    c_item = c_item()                  # manage ManyToMany if only one associated                  if hasattr(c_item, "all"):                      c_items = c_item.all() @@ -781,10 +783,12 @@ class Wizard(NamedUrlWizardView):                  if base_model:                      key = base_model + 's'                      initial.setlist(base_field, [ -                        unicode(val.pk) for val in getattr(obj, key).all()]) +                        unicode(val.pk) for val in getattr(value, key).all()])                  else:                      fields = base_field.split('__')                      for field in fields: +                        if callable(value): +                            value = value()                          if not hasattr(value, field) or \                                  getattr(value, field) is None:                              value = obj | 
