diff options
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r-- | ishtar_common/forms.py | 23 |
1 files changed, 23 insertions, 0 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 |