Source

cmsplugin-poll / cmsplugin_poll / templates / cmsplugin_poll / detail.html

Diff from to

cmsplugin_poll/templates/cmsplugin_poll/detail.html

-{% load i18n %}
+{% load i18n poll_tags %}
 
-<h3>{% trans "Poll" %}</h3>
-<p>
-  <a href="{% url cmsplugin_poll.views.results poll.id %}">
-    {{ poll.question }}
-  </a>
-</p>
+<style>
+  .cmsplugin_poll
+  {
+    padding: 5px;
+    border: 1px solid grey;
+    border-radius: 5px;
+    background-color: white;
+    position: relative;
+  }
 
-{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
+  .cmsplugin_poll .messages .error
+  {
+    color: red;
+  }
 
-<form action="{% url cmsplugin_poll.views.vote poll.id %}" method="post">
-  {% csrf_token %}
-  {% for choice in poll.choice_set.iterator %}
-    <input type="radio" name="choice"
-           id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
-    <label for="choice{{ forloop.counter }}">
-      {{ choice.choice }}
-    </label><br />
-  {% endfor %}
-  <input type="submit" value='{% trans "Vote" %}' />
-</form>
+  .cmsplugin_poll .info
+  {
+    font-size: 75%;
+    color: grey;
+  }
+
+  .cmsplugin_poll ul
+  {
+    list-style-position: inside;
+    padding-left: 0.5em;
+  }
+</style>
+
+<div class="cmsplugin_poll">
+
+  {% show_results request poll as show_results %}
+  {% if show_results %}
+
+    {% include 'cmsplugin_poll/results.html' %}
+
+  {% else %}
+
+    <h4>{% trans "Poll" %}</h4>
+    <h3>{{ poll.question }}</h3>
+
+    {% if messages %}
+      <div class="messages">
+        {% for message in messages %}
+          <span{% if message.tags %} class="{{ message.tags }}"{% endif %}>
+            {{ message }}.
+          </span>
+        {% endfor %}
+      </div>
+    {% endif %}
+
+    <form action="{% url cmsplugin_poll.views.vote poll.id %}" method="post">
+      {% csrf_token %}
+      {% for choice in poll.choice_set.iterator %}
+        <input type="radio" name="choice"
+               id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
+        <label for="choice{{ forloop.counter }}">
+          {{ choice.choice }}
+        </label><br />
+      {% endfor %}
+      <input type="hidden" name="next" value="{{ request.path }}">
+      <input type="submit" value='{% trans "Vote" %}' />
+    </form>
+    <span class="info">
+      {% trans 'Please vote to see the results.' %}
+    </span>
+  {% endif %}
+</div>