From 58568e150d54f4715d4bc91bf0ebefa772a39682 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 21 Oct 2012 19:24:56 +0200 Subject: Djangoization - Major refactoring (step 10) * Fix operation wizards * Minor fix on other wizards --- ishtar_common/templates/base.html | 2 +- ishtar_common/wizards.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index bfc78b166..6e44e8729 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -39,7 +39,7 @@ {% block context %}{% if current_menu %}
- {% trans "Default items"%} + {% trans "Default selected items"%} {% for lbl, model_name, items in current_menu %} diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index fb6ad22e2..373ee0e41 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -551,13 +551,19 @@ class Wizard(NamedUrlWizardView): storage = self.storage if not multi: key = key.startswith(form_key) and key or form_key + '-' + key - return request.session[storage.prefix]['step_data'][form_key][key] + val = request.session[storage.prefix]['step_data'][form_key][key] + if type(val) in (list, tuple): + val = val[0] + return val vals = [] for k in request.session[storage.prefix]['step_data'][form_key]: if k.startswith(form_key) and k.endswith(key) and \ request.session[storage.prefix]['step_data'][form_key][k]: - vals.append(request.session[storage.prefix]['step_data']\ - [form_key][k]) + val = request.session[storage.prefix]['step_data']\ + [form_key][k] + if type(val) in (list, tuple): + val = val[0] + vals.append(val) return vals def get_current_object(self): @@ -567,8 +573,6 @@ class Wizard(NamedUrlWizardView): main_form_key = 'selec-' + self.url_name try: idx = self.session_get_value(main_form_key, 'pk') - if type(idx) in (tuple, list): - idx = idx[0] idx = int(idx) current_obj = self.model.objects.get(pk=idx) except(TypeError, ValueError, ObjectDoesNotExist): -- cgit v1.2.3