From 81727df04417b7c33ed4dfcf9603ad758502a9c0 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 7 Sep 2018 15:56:02 +0200 Subject: QA action: management of confirm page --- ishtar_common/forms.py | 19 ++++++++++++++++++- ishtar_common/templates/ishtar/qa_form.html | 27 +++++++++++++++++++++++---- ishtar_common/views.py | 13 ++++++++++--- 3 files changed, 51 insertions(+), 8 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 2e249e472..c36c9b07d 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -655,7 +655,18 @@ class QAForm(CustomForm, ManageOldType): self.fields.pop(k) continue if self.confirm: - self.fields[k].widget = forms.HiddenInput() + if 'data' not in kwargs or not kwargs['data'].get(k, None): + self.fields.pop(k) + continue + if getattr(self.fields[k].widget, 'allow_multiple_selected', + None): + self.fields[k].widget = forms.MultipleHiddenInput() + else: + self.fields[k].widget = forms.HiddenInput() + if hasattr(self.fields[k], "choices") \ + and k in kwargs['data'] and kwargs['data'][k]: + self.fields[k].rendered_value = dict( + self.fields[k].choices)[int(kwargs['data'][k])] if self.MULTI and k not in self.REPLACE_FIELDS: self.fields[k].label = unicode(self.fields[k].label) + \ unicode(u" - append to existing") @@ -663,6 +674,12 @@ class QAForm(CustomForm, ManageOldType): self.fields[k].label = unicode(self.fields[k].label) + \ unicode(u" - replace") + def save(self, items): + for item in items: + for key in self.cleaned_data: + pass + #setattr(item, key, self.cleaned_data[key]) + class DocumentGenerationForm(forms.Form): """ diff --git a/ishtar_common/templates/ishtar/qa_form.html b/ishtar_common/templates/ishtar/qa_form.html index f3a4cf559..fe373ed57 100644 --- a/ishtar_common/templates/ishtar/qa_form.html +++ b/ishtar_common/templates/ishtar/qa_form.html @@ -16,11 +16,30 @@

{{ error }}

{% endfor %} {% bs_form form %} - {% if confirm %}{% for field in form %} - {% if field.value %} - {{ field.value }} + + {% if confirm %} + +

{% trans "Modified items" %}

+ +

{% trans "Modification" %}

+ + {% for field in form %} + {% if field.value %} + + + + + {% endif %} + {% endfor %} +
{{field.label}}{% trans ":" %} {% if field.field.rendered_value %} + {{ field.field.rendered_value }} + {% else %} + {{ field.value }} + {% endif %} +
{% endif %} - {% endfor %}{% endif %}