{% comment %}
{% extends "newman/edit_inline/tabular.html" %}

{% block header_fields %}
    {% if not field.is_listing_custom_field %}
    {{ block.super }}
    {% endif %}
{% endblock %}

{% block fieldset %}
    <script type="text/javascript">request_media('{{ NEWMAN_MEDIA_URL }}js/inlines.js');</script>
    {% for fieldset in inline_admin_form %}
      {% for line in fieldset %}
        {% for field in line %}

          {# options for question -- to actions (allow_multiple, ...) #}
          {% ifnotequal field.field.name "choices" %}
              <td class="{{ field.field.name }}">
              {{ field.field.errors.as_ul }}
              {{ field.field }}
              </td>
          {% else %}

              {% if inline_admin_formset.formset.can_delete %}
                <td class="delete">
                  {% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}
                </td>
              {% endif %}
              {# customized choice(s) widget, should be the last one#}
              </tr>
              {# custom row for ChoiceCustomWidget #}
              <tr class="choices-head">
                <td colspan="{{ inline_admin_form.field_count }}" id="id_{{ inline_admin_formset.formset.get_default_prefix }}-0-__all__">
                  <h3>{% trans 'Choices' %}</h3>
                </td>
              </tr>
              <tr class="choices-head">
                <th></th>
                <th>{% trans 'Choice text' %}</th>
                <th>{% trans 'Points' %}</th>
                <th>{% trans 'Votes' %}?</th>
                <th>{% trans 'Delete' %}</th>
              </tr>
                  {{ field.field.errors.as_ul }}
                  {{ field.field }}
              <tr> {# open new row due to tabular.html will close row after fieldset block #}
                <td colspan="{{ inline_admin_form.field_count }}">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a class="icn btn add add-choice-button">{% trans "Add" %} {% trans "Choice text" %}</a>
                </td>
          {% endifnotequal %}

        {% endfor %}
      {% endfor %}
    {% endfor %}
{% endblock %}

{% block tabular_quick_sel %}
{% if add %}
<p><a class="icn btn addfav js-placement-main-category">{% trans "Main category" %}</a></p>
{% endif %}
{% endblock %}
{% endcomment %}

<div class="inline-group poll-questions-inline">
    {{ inline_admin_formset.formset.management_form }}
    <script type="text/javascript">
        request_media('{{ NEWMAN_MEDIA_URL }}js/polls.js');
    </script>
    <fieldset class="module" style="margin: 10px;">

        <legend style="font-size: 120%; font-weight: bold;">{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</legend>

        {% for inline_admin_form in inline_admin_formset %}{# traverse questions #}
            <div class="js-poll-question-container">
                {# form errors #}
                {% if inline_admin_form.form.non_field_errors %}
                    <div class="form-errors">{{ inline_admin_form.form.non_field_errors }}</div>
                {% endif %}

                {# question text #}
                <p class="js-poll-question-text-container">
                {% if inline_admin_form.original %}
                    <span>
                        <a class="js-edit-poll-question-text">{{ inline_admin_form.original }}</a>
                    </span>
					<span class="js-poll-options" style="display:block;font-size:.5em;">
						{% trans 'Options' %}
	                    {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}
	                        {% ifnotequal field.field.name "choices" %}{% ifnotequal field.field.name "question" %}
	                            <span title="{{ field.field.name }}">{{ field.field }} {{ field.field.label }}</span>
	                        {% endifnotequal %}{% endifnotequal %}
	                    {% endfor %}{% endfor %}{% endfor %}
					</span>
				{% else %}
                    <span class="js-empty-poll-question-text">
                        <a class="js-edit-poll-question-text icn btn eclear">{% trans 'Click to edit question.' %}</a>
                    </span>
					<span class="js-poll-options" style="display:block;font-size:.5em;">
						{% trans 'Options' %}
	                    {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}
	                        {% ifnotequal field.field.name "choices" %}{% ifnotequal field.field.name "question" %}
	                            <span title="{{ field.field.name }}">{{ field.field }} {{ field.field.label }}</span>
	                        {% endifnotequal %}{% endifnotequal %}
	                    {% endfor %}{% endfor %}{% endfor %}
					</span>
                {% endif %}
                    <span class="js-poll-question-input">
                    {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}
                        {% ifequal field.field.name "question" %}
                            {{ field.field }}
                        {% endifequal %}
                    {% endfor %}{% endfor %}{% endfor %}
                    </span>
                    {# foreign key field (hidden) #}
                    <span class="js-question-foreign-key-fields">
                        {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
                        {{ inline_admin_form.fk_field.field }}
                    </span>
                {% if inline_admin_form.show_url %}
                    <a class="icn web" href="{% url newman:obj-redirect inline_admin_form.original_content_type_id inline_admin_form.original.id %}">{% trans "View on site" %}</a>
                {% endif %}
                </p>

                {# answer options #}
                <div class="js-poll-choices">
                    {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}
                        {% ifequal field.field.name "choices" %}
                            <div>
                                {{ field.field }}
                            </div>
                        {% endifequal %}
                    {% endfor %}{% endfor %}{% endfor %}
                </div>
            </div>
        {% endfor %}{# end traverse questions #}
    </fieldset>
</div>
