From 35cdff7fb2c8fc462fb6644dd5ccf84fb2a596aa 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 --- archaeological_finds/urls.py | 4 ++++ ishtar_common/forms.py | 19 ++++++++++++++++++- ishtar_common/templates/ishtar/qa_form.html | 27 +++++++++++++++++++++++---- ishtar_common/views.py | 13 ++++++++++--- 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index 39da45532..3cbc99f17 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -75,6 +75,10 @@ urlpatterns = [ check_rights(['change_find', 'change_own_find'])( views.QAFindForm.as_view()), name='find-qa-bulk-update'), + url(r'^find-qa-bulk-update/(?P[0-9-]+)?/confirm/$', + check_rights(['change_find', 'change_own_find'])( + views.QAFindForm.as_view()), + name='find-qa-bulk-update-confirm', kwargs={"confirm": True}), url(r'^find-qa-packaging/(?P[0-9-]+)?/$', check_rights(['change_warehouse'])( 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" %}

+
    {% for item in items %} +
  • {{item}}
  • {% endfor %} +
+

{% 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 %}