{% extends 'base.html' %}
{% load wagtailcore_tags wagtailimages_tags molo_forms_tags %}
{% wagtail_site as current_site %}
{% block content %}
<div class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}">
  <div class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__wrapper">
    <div class="heading {% if self.your_words_competition %}heading--hero {% else %}heading--secondary{% endif %}">
      <h1 class="{% if self.your_words_competition %}heading__component {% else %}heading__title{% endif %}">
        {% if self.your_words_competition %}{% trans 'Share your story' %}{% elif self.display_form_directly %}{% trans 'Vote' %}{% else %}{% trans 'Quiz' %}{% endif %}
      </h1>
    </div>

    <div class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__inner">
      {% if not self.display_form_directly %}
        {% if self.image %}
          <aside>
            {% image self.image width-480 as tmp_photo %}
            <img src="{{ tmp_photo.url }}" alt="{{ tmp_photo.title }}" class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__image" />
          </aside>
        {% endif %}
      {% endif %}
      <section>
        {% if self.show_results and results %}
          <h2 class="heading__headline">
            {% if self.your_words_competition %}
              {% with wordSetting='GCN competition' %}
                {% blocktrans %}Your {{wordSetting}} has been completed successfully. See results{% endblocktrans %}
                {% endwith %}
            {% elif self.display_form_directly %}
              {% with wordSetting='poll' %}
                {% blocktrans %}Your {{wordSetting}} has been completed successfully. See results{% endblocktrans %}
                {% endwith %}
            {% else %}
              {% with wordSetting='survey' %}
                {% blocktrans %}Your {{wordSetting}} has been completed successfully. See results{% endblocktrans %}
              {% endwith %}
            {% endif %}
          </h2>
          <ul class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}-results">
            {% for question, answers in results.items %}
              {% for answer, count in answers.items %}
              <li class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}-results__item">
                <label class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__choices-title">{{ question|capfirst }}</label>
                {% if self.show_results_as_percentage %}
                  {{answer}}
                  <div class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__choices-percentage">
                    <div class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__choices-bar" style="width:{{ count }}%">
                      <p class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__choices-subtitle">{{ count }}%</p>
                    </div>
                  </div>
                {% else %}
                  <p class="{% if self.your_words_competition %}yourwords{% elif self.display_form_directly %}polls{% else %}surveys{% endif %}__answers">
                    {{answer}} -
                    {{ count }} vote{{ count|pluralize }}
                  </p>
                {% endif %}
              </li>
              {% endfor %}
            {% endfor %}
          </ul>
        {% else %}
          {% if self.thank_you_text %}
            <h2 class="heading__headline">{% trans "Thank you" %}</h2>
            <h3 class="heading__subtitle">{{self.thank_you_text|url_to_anchor|safe}}</h3>
          {% else %}
            <h2 class="heading__headline">
              {% if self.your_words_competition %}
                {% with wordSetting='GCN competition' %}
                  {% if self.your_words_competition %}
                    {% blocktrans %}Your {{wordSetting}} has been completed successfully!{% endblocktrans %}
                  {% else %}
                    {% blocktrans %}Thank you for submitting this {{wordSetting}}!{% endblocktrans %}
                  {% endif %}
                {% endwith %}
              {% elif self.display_form_directly %}
                {% with wordSetting='poll' %}
                  {% if self.your_words_competition %}
                    {% blocktrans %}Your {{wordSetting}} has been completed successfully!{% endblocktrans %}
                  {% else %}
                    {% blocktrans %}Thank you for submitting this {{wordSetting}}!{% endblocktrans %}
                  {% endif %}
                {% endwith %}
              {% else %}
                {% with wordSetting='survey' %}
                  {% if self.your_words_competition %}
                    {% blocktrans %}Your {{wordSetting}} has been completed successfully!{% endblocktrans %}
                  {% else %}
                    {% blocktrans %}Thank you for submitting this {{wordSetting}}!{% endblocktrans %}
                  {% endif %}
                {% endwith %}
              {% endif %}
            </h2>
          {% endif %}
        {% endif %}
        <nav>
          <div class="call-to-action--group">
            <a href="{{current_site.root_page.specific.url}}" class="call-to-action__button call-to-action__button--previous">
              {% trans "Back home" %}
            </a>
          </div>
        </nav>
      </section>
    </div>
  </div>
</div>
{% endblock %}
