diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-20 19:59:38 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-20 19:59:38 +0100 |
commit | 34e2ab88b6a4e33784f1306bae3e27df1b355739 (patch) | |
tree | c7946c091644647edbb3a4eb27ca5a5bc9def18e /ishtar_common/wizards.py | |
parent | 1d7b5ef3055236b56ec1e104ab66a6ccc8e3da14 (diff) | |
parent | d006f284d408ccc00ba5f93ddd845ef2950f0ea3 (diff) | |
download | Ishtar-34e2ab88b6a4e33784f1306bae3e27df1b355739.tar.bz2 Ishtar-34e2ab88b6a4e33784f1306bae3e27df1b355739.zip |
Merge branch 'master' into v0.9
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r-- | ishtar_common/wizards.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 4f0295421..18336cff5 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -570,8 +570,11 @@ class Wizard(NamedUrlWizardView): # remove non relevant fields all_field_names = self.get_saved_model()._meta.get_all_field_names() for k in dct.copy(): - if (k.endswith('_id') and k[:-3] not in all_field_names) and \ - k not in all_field_names: + if not (k.endswith('_id') and k[:-3] in all_field_names) \ + and k not in all_field_names and \ + (not hasattr(self.get_saved_model(), + 'EXTRA_SAVED_KEYS') or + k not in self.get_saved_model().EXTRA_SAVED_KEYS): dct.pop(k) saved_args = self.saved_args.copy() for k in saved_args: @@ -631,7 +634,11 @@ class Wizard(NamedUrlWizardView): if type(value) == dict: model = related_model.model if hasattr(related_model, 'through') and \ - related_model.through: + related_model.through and \ + hasattr(related_model.through, 'RELATIVE_MODELS') \ + and self.get_saved_model() in \ + related_model.through.RELATIVE_MODELS: + # the form is dealing with the through parameter model = related_model.through # not m2m -> foreign key if not hasattr(related_model, 'clear'): @@ -687,7 +694,9 @@ class Wizard(NamedUrlWizardView): return return_object and (obj, res) or res def get_deleted(self, keys): - """Get the deleted and non-deleted items in formsets""" + """ + Get the deleted and non-deleted items in formsets + """ not_to_delete, to_delete = set(), set() for key in keys: items = key.split('-') |