Add state for votes
This commit is contained in:
parent
abc26f733f
commit
aefc722c9d
5 changed files with 177 additions and 49 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
<p><%= @vote.description %></p>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/draft" method="post">
|
||||
<button type="submit">Change back to draft vote</button>
|
||||
</form>
|
||||
|
||||
<h2>Organizers</h2>
|
||||
|
||||
<ul>
|
||||
|
|
@ -10,13 +14,13 @@
|
|||
<% end %>
|
||||
</ul>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/organizers" method="post">
|
||||
<p>
|
||||
<label for="email">Email</label>
|
||||
<input type="text" name="email">
|
||||
</p>
|
||||
<button type="submit">Add new organizer</button>
|
||||
</form>
|
||||
<h2>Participants</h2>
|
||||
|
||||
<ul>
|
||||
<% @vote.ratings.collect { |rating| rating.user }.uniq.each do |user| %>
|
||||
<li><%= user.email %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<h2>Your ratings</h2>
|
||||
|
||||
|
|
@ -43,45 +47,8 @@
|
|||
<button type="submit">Save ratings</button>
|
||||
</form>
|
||||
|
||||
<h2>All ratings</h2>
|
||||
<h2>Close voting period</h2>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Participant</th>
|
||||
<% @vote.candidates.each do |candidate| %>
|
||||
<th><%= candidate.name %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% @vote.ratings.collect { |rating| rating.user }.uniq.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.email %></td>
|
||||
<% @vote.candidates.each do |candidate| %>
|
||||
<% if rating = @vote.ratings.find { |rating| rating.user == user and rating.candidate == candidate } %>
|
||||
<td><%= rating.value %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<h2>Results</h2>
|
||||
|
||||
<ol>
|
||||
<% @vote.candidates.sort { |a, b| a.mj <=> b.mj }.reverse.each do |candidate| %>
|
||||
<li><%= candidate.name %>: <%= candidate.mj.mj %></li>
|
||||
<% end %>
|
||||
</ol>
|
||||
|
||||
<h2>New candidate</h2>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/candidates" method="post">
|
||||
<p>
|
||||
<label for="name">Name</label>
|
||||
<input type="text" name="name">
|
||||
</p>
|
||||
<p>
|
||||
<label for="description">Description</label>
|
||||
<input type="text" name="description">
|
||||
</p>
|
||||
<button type="submit">Add new candidate</button>
|
||||
<form action="/votes/<%= @vote.secure_id %>/close" method="post">
|
||||
<button type="submit">Show results</button>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue