summaryrefslogtreecommitdiff
path: root/ishtar_common/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-08 02:34:24 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-08 02:34:24 +0100
commitbb482fb0d9e54498785f1a16a984d92de6c8ea86 (patch)
tree57dee09f66247af329e2aab0cea62b4b26165025 /ishtar_common/wizards.py
parent969eda7b6d5d8eafffab1279a223f9172f403837 (diff)
parent89c66a92b539ab4cc682cf8c774dc65db6c3ba39 (diff)
downloadIshtar-bb482fb0d9e54498785f1a16a984d92de6c8ea86.tar.bz2
Ishtar-bb482fb0d9e54498785f1a16a984d92de6c8ea86.zip
Merge branch 'master' into v0.9
Diffstat (limited to 'ishtar_common/wizards.py')
-rw-r--r--ishtar_common/wizards.py20
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