{% extends "sakai/base.html" %}{% load sakai %}

{% block content %}

{% regroup polls by siteId as polls_by_siteId %}

{% for poll_set in polls_by_siteId %}
<div class="section">
  <div class="header">
    <h2>{{ poll_set.list.0.siteTitle }}</h2>
  </div>

  <table class="content">
    <thead>
      <tr>
        <th>Question</th>
        <th>Status</th>
        <th></th>
    <tbody>
{% for poll in poll_set.list %}
      <tr>
        <td>{{ poll.text }}</td>
        <td>
          {% if poll.hasOpened %}
            Closes in <strong>{{ poll.voteClose|timeuntil }}</strong>.
          {% else %}
            Opens in <strong>{{ poll.voteOpen|timeuntil }}</strong> for <strong>{{ poll.voteClose|timeuntil:poll.voteOpen }}</strong>.
          {% endif %}
        </td>
        <td>
          <div class="button">
            <a href="{% url sakai:poll-detail poll.id %}">{% if poll.mayVote %}Vote!{% else %}View{% endif %}</a>
          </div>
        </td>
      </tr>
{% endfor %}
    </tbody>
  </table>
</div>

{% empty %}
<div class="section">
  <div class="header">
    <h2>Polls</h2>
  </div>
  <div class="section-content">
    There aren't currently any polls.
  </div>
</div>
{% endfor %}

{% endblock %}

{% extends "sakai/base.html" %}{% load sakai %}

{% block content %}

{% regroup polls by siteId as polls_by_siteId %}

{% for poll_set in polls_by_siteId %}
<div class="section">
  <div class="header">
    <h2>{{ poll_set.list.0.siteTitle }}</h2>
  </div>

  <table class="content">
    <thead>
      <tr>
        <th>Question</th>
        <th>Status</th>
        <th></th>
    <tbody>
{% for poll in poll_set.list %}
      <tr>
        <td>{{ poll.text }}</td>
        <td>
          {% if poll.hasOpened %}
            Closes in <strong>{{ poll.voteClose|timeuntil }}</strong>.
          {% else %}
            Opens in <strong>{{ poll.voteOpen|timeuntil }}</strong> for <strong>{{ poll.voteClose|timeuntil:poll.voteOpen }}</strong>.
          {% endif %}
        </td>
        <td>
          <div class="button">
            <a href="{% url sakai:poll-detail poll.pollId %}">{% if poll.mayVote %}Vote!{% else %}View{% endif %}</a>
          </div>
        </td>
      </tr>
{% endfor %}
    </tbody>
  </table>
</div>

{% empty %}
<div class="section">
  <div class="header">
    <h2>Polls</h2>
  </div>
  <div class="section-content">
    There aren't currently any polls.
  </div>
</div>
{% endfor %}

{% endblock %}

Stop partially created polls breaking the list of polls
Stop partially created polls breaking the list of polls
