aboutsummaryrefslogtreecommitdiffstats
path: root/templates/poll_vote_table.html.j2
blob: 440f2b7d2fcd5834b825a89366d6b03478f46e27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<table class="vote-table">
  <tr>
    <th></th>
    {% for choice in choices %}
    <th>
      {% include "poll_choice_datetime_range.html.j2" %}
      <span>
        <i>{{ choice.votes_with_value(1) | length }} votes</i>
      </span>
    </th>
    {% endfor %}
  </tr>
  {% for voter_name in voter_names %}
  <tr>
    <td>
      {% if voter_name in managed_voter_names %}
      <form action="/poll/{{ poll.id }}/delete_voter" method="post">
        <input type="hidden" name="voter_code" value="{{ managed_voter_names[voter_name] }}">
        {{ voter_name }}
        <input class="delete-voter-btn" type="submit" value="❌">
      </form>
      {% else %}
      {{ voter_name }}
      {% endif %}
    </td>
    {% for choice in choices %}
    {% if selections[(voter_name, choice.id)] == 1 %}
    <td>
      <input type="checkbox" checked disabled>
    </td>
    {% elif selections[(voter_name, choice.id)] == 0 %}
    <td>
      <input type="checkbox" disabled>
    </td>
    {% else %}
    <td>
      ??
    </td>
    {% endif %}
    {% endfor %}
  </tr>
  {% endfor %}

  <!-- Add a row for the current user -->
  <form action="/poll/{{ poll.id }}/vote" method="post">
  <tr>
    <td>
      <label for="voter_name" hidden>Your name</label>
      <input type="text" name="voter_name" placeholder="Your name" required
             {% if prefill_voter_name %}value="{{ prefill_voter_name }}"{% endif %}>
      <input class="green" type="submit" value="Submit">
    </td>
    {% for choice in choices %}
    <td>
      <input type="checkbox" name="choice_{{ choice.id }}">
    </td>
    {% endfor %}
  </tr>
  </form>
  <!-- End of the row for the current user -->
</table>