vedia/views/votes_show_open.erb

66 lines
1.7 KiB
Text

<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| %>
<% rating = @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate } %>
<% value = rating ? rating.value : 0 %>
<li>
<p><%= candidate.name %></p>
<p><%= candidate.description %></p>
<ol>
<% settings.values.reverse.each do |v| %>
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-<%= v[:id] %>" value="<%= v[:id] %>" <% if value == v[:id] %>checked<% end %>><label for="<%= candidate.id %>-<%= v[:id] %>"><%= v[:label] %></label>
<% end %>
</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 %>