91 lines
2.3 KiB
Text
91 lines
2.3 KiB
Text
<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 } %>
|
|
<% value = settings.values.select { |e| e[:id] == rating.value }.first %>
|
|
<td class="value-<%= value[:id] %>"><%= value[:label] %></td>
|
|
<% end %>
|
|
<% end %>
|
|
</tr>
|
|
<% end %>
|
|
</table>
|
|
|
|
<h2><%= _("Results") %></h2>
|
|
|
|
<table>
|
|
<tr>
|
|
<th><%= _("Rank") %></th>
|
|
<th><%= _("Candidate") %></th>
|
|
<th><%= _("Majority Judgment") %></th>
|
|
<th><%= _("Proponents") %></th>
|
|
<th><%= _("Opponents") %></th>
|
|
</tr>
|
|
<% i = 0 %>
|
|
<% @vote.candidates.sort { |a, b| a.mj <=> b.mj }.reverse.each do |candidate| %>
|
|
<% i = i + 1 %>
|
|
<tr>
|
|
<td><%= i %></td>
|
|
<td><%= candidate.name %></td>
|
|
<% value = settings.values.select { |e| e[:id] == candidate.mj.mj }.first %>
|
|
<td class="value-<%= value[:id] %>"><%= value[:label] %></td>
|
|
<td><%= candidate.mj.proponents %></td>
|
|
<td><%= candidate.mj.opponents %></td>
|
|
</tr>
|
|
<% end %>
|
|
</table>
|
|
|
|
<%
|
|
data = []
|
|
colors = []
|
|
settings.values.reverse.each do |v|
|
|
d = { name: v[:label], data: [] }
|
|
@vote.candidates.each do |c|
|
|
d[:data] << [c.name, c.mj.count[v[:id]]]
|
|
end
|
|
data << d
|
|
colors << v[:color]
|
|
end
|
|
%>
|
|
<%= bar_chart data, colors: colors, stacked: true, legend: 'bottom' %>
|
|
|
|
<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 %>/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 organizer") %></button>
|
|
</form>
|
|
|
|
<% end %>
|