{% extends "base.html" %} {% comment %}This view is used to create or edit a ``mtp.apps.surveys.Question`` instance. Context ------- pool : instance of ``mtp.apps.surveys.models.Pool`` The pool for which we display the questions. question : instance of ``mtp.apps.surveys.models.Question`` The question to edit or create. form : instance of ``django.forms.models.ModelForm`` The form to created/edit the question (pre-filled if it's an edition). choices_formset : instance of ``mtp.apps.surveys.forms.ChoicesFormSet`` The editable list of choices for the current question. Notes ----- If ``question.pk`` is "falsy", then we assume that's it's new question to be created, else it's an existing question to update. {% endcomment %} {% load i18n template_tools %} {% block body_class %}{{ block.super }} page-cms-surveys page-cms-surveys-questions{% endblock %} {% block head %} {{ block.super }} {% include "cms/includes/orderable-inline-head.html" %} {% endblock %} {% block subtitle %} {% if question.pk %} {% blocktrans trimmed with pool_name=pool.name question_title=question.title %} Edit the question "{{ question_title }}" of the pool "{{ pool_name }}" {% endblocktrans %} {% else %} {% blocktrans trimmed with pool_name=pool.name %} Add a question in the pool "{{ pool_name }}" {% endblocktrans %} {% endif %} {% endblock %} {% block actions %} {% trans 'Back to the list of questions' %} {% trans 'Back to the pool' %} {% endblock %} {% block main %} {% if form.errors or choices_formset.errors %}
{% trans 'Please correct errors below.' %} {% if form.non_field_errors %} {{ form.non_field_errors }} {% endif %}
{% endif %} {% reducespaces %}
{% endreducespaces %}{% csrf_token %} {{ form.media }} {{ choices_formset.management_form }} {% for field in form.hidden_fields %} {{ field }} {% endfor %} {% for field in form.visible_fields %} {% endfor %}
{{ field.label_tag }} {% if field.errors %}
{{ field.errors }}
{% endif %} {{ field }}

{% trans 'Choices' %}

{% if choices_formset.non_field_errors %}
{{ choices_formset.non_field_errors }}
{% endif %}
  • {% blocktrans trimmed count min=view.model.MIN_CHOICES with max=view.model.MAX_CHOICES %} You must enter at least 1 choice, at max {{ max }}. {% plural %} You must enter at least {{ min }} choices, at max {{ max }}. {% endblocktrans %}
{% for choice_form in choices_formset %} {% reducespaces %}
{% endreducespaces %}

{% blocktrans trimmed with choice_number=forloop.counter %} Choice #{{ choice_number }} {% endblocktrans %} {% if choice_form.instance and choice_form.instance.pk %} {{ choice_form.DELETE.label }} {{ choice_form.DELETE }} {% endif %}

{% for field in choice_form.hidden_fields %} {{ field }} {% endfor %} {% for field in choice_form.visible_fields %}{% if field.name != 'DELETE' %} {% endif %}{% endfor %}
{{ field.label_tag }} {% if field.errors %}
{{ field.errors }}
{% endif %} {{ field }}
{% endfor %}
{% if question.pk %} {% trans 'Delete this question' %} {% else %} {% endif %}
{% endblock %}