Require being an organizer to modify the state and organizers of a vote
This commit is contained in:
parent
d81c2b2ccf
commit
59d535e534
3 changed files with 80 additions and 49 deletions
60
views/votes_show_closed.erb
Normal file
60
views/votes_show_closed.erb
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<h1><%= @vote.title %></h1>
|
||||
|
||||
<p><%= @vote.description %></p>
|
||||
|
||||
<h2>All ratings</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>
|
||||
|
||||
<% if @vote.users.exists?(current_user.id) %>
|
||||
|
||||
<h2>Organizers</h2>
|
||||
|
||||
<ul>
|
||||
<% @vote.organizers.each do |organizer| %>
|
||||
<li><%= organizer.user.email %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<h3>Actions for organizers</h3>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/reopen" method="post">
|
||||
<button type="submit">Reopen voting period</button>
|
||||
</form>
|
||||
|
||||
<h3>Add organizer</h3>
|
||||
|
||||
<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>
|
||||
|
||||
<% end %>
|
||||
Loading…
Add table
Add a link
Reference in a new issue