diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/forms.py | 23 | ||||
-rw-r--r-- | ishtar_common/static/media/style.css | 2 | ||||
-rw-r--r-- | ishtar_common/wizards.py | 28 |
3 files changed, 40 insertions, 13 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index b851c95b2..2e170fd1e 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -164,6 +164,29 @@ def get_form_selection( return type(class_name, (forms.Form,), attrs) +def get_data_from_formset(data): + """ + convert ['formname-wizardname-1-public_domain': [u'on'], ...] to + [{'public_domain': 'off'}, {'public_domain': 'on'}] + """ + values = [] + for k in data: + if not data[k]: + continue + keys = k.split('-') + if len(keys) < 3: + continue + try: + idx = int(keys[-2]) + except ValueError: + continue + while len(values) < (idx + 1): + values.append({}) + field_name = keys[-1] + values[idx][field_name] = data[k] + return values + + class DocumentGenerationForm(forms.Form): """ Form to generate document by choosing the template diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 09005ce84..a0f117f1d 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -1108,7 +1108,7 @@ a.remove{ } .form p.input input.widget-parcel{ - width:85px; + width:50px; } .small, .small input{ diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index f028c15d8..1ac28d640 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -662,19 +662,23 @@ class Wizard(NamedUrlWizardView): frm = form.form if callable(frm): frm = frm() - required_fields = [ki for ki in frm.fields - if frm.fields[ki].required] - base_key = None - if required_fields: - base_key = required_fields[-1] - elif frm.fields.keys(): - base_key = frm.fields.keys()[-1] - init = self.get_form_initial(step, data=data) + total_field = 0 - if base_key: - total_field = len([key for key in data.keys() - if base_key in key.split('-') - and data[key]]) + if hasattr(frm, 'count_valid_fields'): + total_field = frm.count_valid_fields(data) + else: + required_fields = [ki for ki in frm.fields + if frm.fields[ki].required] + base_key = None + if required_fields: + base_key = required_fields[-1] + elif frm.fields.keys(): + base_key = frm.fields.keys()[-1] + if base_key: + total_field = len([key for key in data.keys() + if base_key in key.split('-') + and data[key]]) + init = self.get_form_initial(step, data=data) if init and not to_delete and ( not hasattr(self, 'form_initialized') or not self.form_initialized): |