{% extends 'base.html' %}
{% load wagtailcore_tags wagtailimages_tags static molo_forms_tags %}
{% wagtail_site as current_site %}
{% block content %}
  {% if self.your_words_competition %}
    <div class="standalone-page your-words your-words{{ self.get_effective_extra_style_hints }}">
  {% elif self.display_form_directly %}
    <div class="standalone-page polls gem-polls">
  {% else %}
    <div class="surveys surveys{{ self.get_effective_extra_style_hints }}">
  {% endif %}

    {% if self.your_words_competition %}
      <div class="section-title">
        <h2>{% trans "Share your story" %}</h2>
      </div>
      <h3>{% trans 'Thank you!' %}</h3>
      <img src="{% static 'img/Pencil.png' %}" />
      <h4 class="surveys__thank-you">
        {% if self.thank_you_text %}
          {{ self.thank_you_text|url_to_anchor|safe }}
        {% else %}
          {% trans "Thanks for submitting your story! You’ll find out soon if you’re a winner!" %}
        {% endif %}
      </h4>
    {% elif self.display_form_directly %}
      <h4 class="poll__title list-header">{% trans "What's your opinion?" %}</h4>
      <div class="list-inline">
      {% if self.show_results and results %}
          {% for question, answers in results.items %}
            <h3 class="polls__question">{{ question }}</h3>
              {% for answer, count in answers.items %}
              <div class="choices">
                <p>{{ answer }}
                  {% if self.show_results_as_percentage %}
                    <span class="choices--percentage">{{ count }}%</span>
                  {% else %}
                    <span class="choices--result">{{ count }} vote{{ count|pluralize }}</span>
                  {% endif %}
                </p>
              </div>
              {% endfor %}
          {% endfor %}
      {% else %}
        <div class="poll__form-block">
          <h2 class="poll__question-title">{{ self.title }}</h2>
          {% if self.thank_you_text %}
            <h3 class="poll__title">{{ self.thank_you_text|url_to_anchor|safe }}</h3>
          {% else %}
            <h3 class="poll__title">
              {% trans "Thank you for submitting poll!" %}
            </h3>
          {% endif %}
        </div>
      {% endif %}
      </div>
    {% elif self.article_form_only or self.contact_form  %}
      <h1 class="surveys__title">{{self.title}}</h1>
      <h4 class="surveys__thank-you">
        {% if self.thank_you_text %}
          {{ self.thank_you_text|url_to_anchor|safe }}
        {% else %}
          {% trans "Thank you for submitting the form." %}
        {% endif %}
      </h4>
      {% if self.show_results and results %}
        <h4 class="surveys__thank-you">
        {% trans "The form has been completed successfully." %}
      </h4>
      {% endif %}
    {% else %}
      <h1 class="surveys__title">{% trans "Survey Results" %}</h1>
      <h4 class="surveys__thank-you">
        {% if self.thank_you_text %}
          {{ self.thank_you_text|url_to_anchor|safe }}
        {% else %}
          {% trans "Thank you for submitting survey!" %}
        {% endif %}
      </h4>
      {% if self.show_results and results %}
        <h4 class="surveys__thank-you">
        {% trans "Your survey has been completed successfully." %}
      </h4>
      {% endif %}
    {% endif %}

    <div class="call-to-action">
      <a href="{{current_site.root_page.specific.url}}" class="button call-to-action__nav-item call-to-action__nav-item--back-home">
      {% trans "Back to Home page" %}</a>
    </div>
  {% if self.your_words_competition %}</div>
  {% elif self.display_form_directly %}</div>
  {% else %}</div>{% endif %}
{% endblock %}
