summaryrefslogtreecommitdiff
path: root/ishtar_common/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-08 02:31:55 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-08 02:31:55 +0100
commitc70af314a07f8b1ad84cf8b55806714ed408b6f1 (patch)
tree00a5895af500d0c1d5785d31c1def309cf1b563c /ishtar_common/wizards.py
parentb0a48f170a51b7239960aadcc501e23b9af339c2 (diff)
downloadIshtar-c70af314a07f8b1ad84cf8b55806714ed408b6f1.tar.bz2
Ishtar-c70af314a07f8b1ad84cf8b55806714ed408b6f1.zip
Fix default item after creations
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