diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-12-23 22:15:34 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-12-23 22:15:34 +0100 | 
| commit | 167068ad8073f52780e64d09668fe9b7557085e1 (patch) | |
| tree | 5ebd08808fbbc580392c11dc70a0ed29fef99480 /ishtar_common/wizards.py | |
| parent | 291aaf52135ace669b6fc86f43d5f6420c0c4435 (diff) | |
| download | Ishtar-167068ad8073f52780e64d09668fe9b7557085e1.tar.bz2 Ishtar-167068ad8073f52780e64d09668fe9b7557085e1.zip | |
Container: Localisation form become modification form
Diffstat (limited to 'ishtar_common/wizards.py')
| -rw-r--r-- | ishtar_common/wizards.py | 14 | 
1 files changed, 12 insertions, 2 deletions
| diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 6e5216c6a..ad16ce0e1 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -127,6 +127,8 @@ class Wizard(NamedUrlWizardView):      wizard_templates = {}      filter_owns = {}      current_obj_slug = '' +    current_object_key = 'pk' +    ignore_init_steps = []      file_storage = default_storage      saved_args = {}  # argument to pass on object save @@ -200,6 +202,10 @@ class Wizard(NamedUrlWizardView):              templates = [self.wizard_confirm] + templates          return templates +    def get_ignore_init_steps(self): +        return ['{}-{}'.format(step, self.url_name) for step in +                self.ignore_init_steps] +      def get_context_data(self, form, **kwargs):          """Add previous, next and current steps to manage the wizard path"""          context = super(Wizard, self).get_context_data(form) @@ -254,7 +260,8 @@ class Wizard(NamedUrlWizardView):                              for key in v:                                  form_key = next_step + prefix + key                                  prefixed_values[form_key] = v[key] -                    if not prefixed_values: +                    if not prefixed_values and \ +                            next_step not in self.get_ignore_init_steps():                          # simulate a non empty data for form that might be                          # valid when empty                          prefixed_values['__non_empty_data'] = '' @@ -481,6 +488,9 @@ class Wizard(NamedUrlWizardView):              for k in dct:                  if k.startswith('pk'):                      continue +                if k not in obj.__class__._meta.get_all_field_names(): +                    print(k, obj.__class__._meta.get_all_field_names()) +                    continue                  # False set to None for images and files                  if not k.endswith('_id') and (                     isinstance(obj.__class__._meta.get_field(k), FileField) or @@ -914,7 +924,7 @@ class Wizard(NamedUrlWizardView):          current_obj = None          main_form_key = 'selec-' + self.url_name          try: -            idx = self.session_get_value(main_form_key, 'pk') +            idx = self.session_get_value(main_form_key, self.current_object_key)              idx = int(idx)              current_obj = self.model.objects.get(pk=idx)          except(TypeError, ValueError, ObjectDoesNotExist): | 
