diff options
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r-- | ishtar_common/wizards.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index ffbf9b994..0b121fd76 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -103,6 +103,7 @@ class Wizard(NamedUrlWizardView): wizard_confirm = 'ishtar/wizard/confirm_wizard.html' wizard_templates = {} filter_owns = {} + current_obj_slug = '' @staticmethod def _check_right(step, condition=True): @@ -592,6 +593,10 @@ class Wizard(NamedUrlWizardView): # necessary to manage interaction between models like # material_index management for baseitems obj.save() + # make the new object a default + if self.current_obj_slug: + self.request.session[self.current_obj_slug] = unicode(obj.pk) + self.request.session[self.get_object_name(obj)] = unicode(obj.pk) dct = {'item': obj} # force evaluation of lazy urls wizard_done_window = unicode(self.wizard_done_window) @@ -876,17 +881,20 @@ class Wizard(NamedUrlWizardView): return initial return super(Wizard, self).get_form_initial(step) - def get_instanced_init(self, obj, step=None): - """Get initial data from an init""" - current_step = step or self.steps.current - c_form = self.form_list[current_step] - # make the current object the default item for the session + def get_object_name(self, obj): obj_name = obj.__class__.__name__.lower() # prefer a specialized name if available prefixes = self.storage.prefix.split('_') if len(prefixes) > 1 and prefixes[-2].startswith(obj_name): obj_name = prefixes[-2] - self.request.session[obj_name] = unicode(obj.pk) + return obj_name + + def get_instanced_init(self, obj, step=None): + """Get initial data from an init""" + current_step = step or self.steps.current + c_form = self.form_list[current_step] + # make the current object the default item for the session + self.request.session[self.get_object_name(obj)] = unicode(obj.pk) initial = MultiValueDict() if self.request.POST or \ (step in self.request.session[self.storage.prefix] and |