{% extends "base.html" %} {% comment %}This view is used to edit a ``mtp.apps.surveys.Survey`` instance. As surveys are automatically generated, this is only to to dsplay the pools and manage their ``is_displayed`` flags. Context ------- survey : instance of ``mtp.apps.surveys.models.Survey`` The survey for which we display the polss. form : instance of ``django.forms.models.ModelForm`` The form to edit the survey. Does not include any editable fields. pools_formset : instance of ``mtp.apps.surveys.forms.SurveyPoolsFormSet`` The editable list of pools for the current survey. pool_forms : list A list of two entries, each one being a tuple with:: - a boolean indicating if the current entry is related to global pools or not - an extract of ``pools_formset`` containing only global or non global pools Notes ----- The list of pools is currently two lists, one with the global pools, one with the ones owned by the user. {% endcomment %} {% load i18n %} {% block body_class %}{{ block.super }} page-cms-surveys page-cms-surveys-surveys{% endblock %} {% block subtitle %} {% blocktrans trimmed with training_name=survey.training.name %} Edit the survey for the training "{{ training_name }}" {% endblocktrans %} {% endblock %} {% block actions %} {% trans 'Back to the training' %} {% trans 'Back to your pools' %} {% endblock %} {% block main %} {% if form.errors or pools_formset.errors %}
{% trans 'Please correct errors below.' %} {% if form.non_field_errors %} {{ form.non_field_errors }} {% endif %}
{% endif %}
{% csrf_token %} {{ form.media }} {{ pools_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 'Choose the pools of questions you want to display for this training.' %}

{% if pools_formset.non_field_errors %}
{{ pools_formset.non_field_errors }}
{% endif %} {% for pool_form in pools_formset %} {% for field in pool_form.hidden_fields %} {{ field }} {% endfor %} {% endfor %} {% for is_global, forms in pool_forms %} {% for pool_form in forms %} {% with pool_survey=pool_form.instance pool=pool_form.instance.pool %} {% if pool.is_mandatory %} {% else %} {{ pool_form.is_displayed }} {% endif %} {% endwith %} {% endfor %}
{% if is_global %} {% trans 'Global pools' %} {% else %} {% trans 'Your pools' %} {% endif %}
{% trans 'Pool'%} {% trans 'Mandatory'%} {% trans 'Displayed'%}
{{ pool.name }} ({% blocktrans trimmed count nb_questions=pool_survey.count_questions %} {{ nb_questions }} question {% plural %} {{ nb_questions }} questions {% endblocktrans %}) {% if pool_form.instance.is_new %} {% trans 'new' %} {% endif %} {% if pool.is_mandatory %} {% else %} {% endif %}
{% endfor %}
{% endblock %}