From f41b22f173bb9c9c331fa9eab2a7a8d47d0a57db Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 4 Apr 2013 20:49:29 +0200 Subject: Inline formset to manage parcels --- ishtar_common/templates/blocks/form_snippet.html | 13 ++++++++++ ishtar_common/templates/blocks/inline_formset.html | 25 +++++++++++++++++++ ishtar_common/templates/form_snippet.html | 13 ---------- .../templates/ishtar/wizard/default_wizard.html | 4 ++++ .../templates/ishtar/wizard/parcels_wizard.html | 28 ++++++++++++++++++++++ .../templates/ishtar/wizard/towns_wizard.html | 10 +------- 6 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 ishtar_common/templates/blocks/form_snippet.html create mode 100644 ishtar_common/templates/blocks/inline_formset.html delete mode 100644 ishtar_common/templates/form_snippet.html create mode 100644 ishtar_common/templates/ishtar/wizard/parcels_wizard.html (limited to 'ishtar_common/templates') diff --git a/ishtar_common/templates/blocks/form_snippet.html b/ishtar_common/templates/blocks/form_snippet.html new file mode 100644 index 000000000..2f841e078 --- /dev/null +++ b/ishtar_common/templates/blocks/form_snippet.html @@ -0,0 +1,13 @@ +{% load i18n %} + {% if form.non_field_errors %} + {{form.non_field_errors}} + {%endif%} + {% for field in form %}{% if not field.is_hidden %} + + {{ field.label_tag }} + {{ field.errors }}{{field|safe}}{% if field.help_text %} + ? + + +
{{field.help_text}}
+ {%endif%}{% else %}{{field}}{% endif %}{% endfor %} diff --git a/ishtar_common/templates/blocks/inline_formset.html b/ishtar_common/templates/blocks/inline_formset.html new file mode 100644 index 000000000..e36405118 --- /dev/null +++ b/ishtar_common/templates/blocks/inline_formset.html @@ -0,0 +1,25 @@ +{% load i18n %} + {% if extra_formset.non_form_errors %}
{{extra_formset.non_form_errors.as_ul}}
{% endif %} + {% if header %} + + {% endif %}{% for frm in formset%}{% if header %} + {% for field in frm.visible_fields%} + {%endfor%} + + {% endif %} + {% if forloop.first and not skip %}{%endif%} + {% if not skip or not forloop.first %}{% endif %}{% for field in frm.visible_fields %} + {% endfor %} + {% if not skip or not forloop.last %}{% endif %}{%endfor%} + {% if not skip %}{% endif %}{% if header %} +
{% trans caption %}
{{field.label}}
+ {% if field.errors %}
{{ field.errors.as_ul }}
{% endif %} + {{ field }} + {# Include the hidden fields in the form #} + {% if forloop.first %} + {{ formset.management_form }} + {% for hidden in frm.hidden_fields %} + {{ hidden }} + {% endfor %} + {% endif %} +
{% endif %} diff --git a/ishtar_common/templates/form_snippet.html b/ishtar_common/templates/form_snippet.html deleted file mode 100644 index 2f841e078..000000000 --- a/ishtar_common/templates/form_snippet.html +++ /dev/null @@ -1,13 +0,0 @@ -{% load i18n %} - {% if form.non_field_errors %} - {{form.non_field_errors}} - {%endif%} - {% for field in form %}{% if not field.is_hidden %} - - {{ field.label_tag }} - {{ field.errors }}{{field|safe}}{% if field.help_text %} - ? - - -
{{field.help_text}}
- {%endif%}{% else %}{{field}}{% endif %}{% endfor %} diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index e2abc80b6..b56324a78 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -6,6 +6,7 @@ {{form.media}} {% endblock %} {% block content %} +{% block wizard_head %}

{{wizard_label}}

{% csrf_token %}
    @@ -17,6 +18,8 @@
  • » 
  • {% endfor %}
+{% endblock %} +{% block wizard_form %}
{% if reminder %}
{{ reminder }}
{%endif%} {{ wizard.form.media }} @@ -43,3 +46,4 @@
{% endblock %} +{% endblock %} diff --git a/ishtar_common/templates/ishtar/wizard/parcels_wizard.html b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html new file mode 100644 index 000000000..94e9820ab --- /dev/null +++ b/ishtar_common/templates/ishtar/wizard/parcels_wizard.html @@ -0,0 +1,28 @@ +{% extends "ishtar/wizard/default_wizard.html" %} +{% load i18n range inline_formset %} +{% block extra_head %} +{{wizard.form.media}} +{% endblock %} +{% block wizard_form %} +
+{% if reminder %}
{{ reminder }}
{%endif%} +{{ wizard.form.media }} +{{ wizard.management_form }} + {{ wizard.form.management_form }} +
+ {%if wizard.form.non_form_errors%} + + +
{{wizard.form.non_form_errors}}
{%endif%} + + {% for field in wizard.form.forms.0 %}{% endfor %} + {% inline_formset 'Parcels' wizard.form.forms False %} +
{{ field.label_tag }}
+

+ +{{ previous_fields|safe }} + +{% if next_steps %}{% endif %} +
+ +{% endblock %} diff --git a/ishtar_common/templates/ishtar/wizard/towns_wizard.html b/ishtar_common/templates/ishtar/wizard/towns_wizard.html index cd40e6049..cc3487df3 100644 --- a/ishtar_common/templates/ishtar/wizard/towns_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/towns_wizard.html @@ -4,15 +4,7 @@ {% block extra_head %} {{wizard.form.media}} {% endblock %} -{% block content %} -

{{wizard_label}}

-
{% csrf_token %} - +{% block wizard_form %}
{% if TOWNS %} {% if wizard.form.forms %} -- cgit v1.2.3