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
68
views/votes_show_open.erb
Normal file
68
views/votes_show_open.erb
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<h1><%= @vote.title %></h1>
|
||||
|
||||
<p><%= @vote.description %></p>
|
||||
|
||||
<h2>Your ratings</h2>
|
||||
|
||||
<p>Hello, <%= current_user.email %>.</p>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/ratings" method="post">
|
||||
<ul>
|
||||
<% @vote.candidates.each do |candidate| %>
|
||||
<li>
|
||||
<p><%= candidate.name %></p>
|
||||
<p><%= candidate.description %></p>
|
||||
<ol>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-7" value="7" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 7 } %>checked<% end %>><label for="<%= candidate.id %>-7">Excellent</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-6" value="6" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 6 } %>checked<% end %>><label for="<%= candidate.id %>-6">Very good</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-5" value="5" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 5 } %>checked<% end %>><label for="<%= candidate.id %>-5">Good</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-4" value="4" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 4 } %>checked<% end %>><label for="<%= candidate.id %>-4">Mediocre</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-3" value="3" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 3 } %>checked<% end %>><label for="<%= candidate.id %>-3">Bad</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-2" value="2" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 2 } %>checked<% end %>><label for="<%= candidate.id %>-2">Very bad</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-1" value="1" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 1 } %>checked<% end %>><label for="<%= candidate.id %>-1">Awful</label>
|
||||
</ol>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<button type="submit">Save ratings</button>
|
||||
</form>
|
||||
|
||||
<h2>Participants</h2>
|
||||
|
||||
<ul>
|
||||
<% @vote.ratings.collect { |rating| rating.user }.uniq.each do |user| %>
|
||||
<li><%= user.email %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<h2>Organizers</h2>
|
||||
|
||||
<ul>
|
||||
<% @vote.organizers.each do |organizer| %>
|
||||
<li><%= organizer.user.email %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<% if @vote.users.exists?(current_user.id) %>
|
||||
|
||||
<h3>Actions for organizers</h3>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/draft" method="post">
|
||||
<button type="submit">Change back to draft vote</button>
|
||||
</form>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/close" method="post">
|
||||
<button type="submit">Close votes and show results</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