86 lines
2.4 KiB
Text
86 lines
2.4 KiB
Text
<h1><%= @vote.title %></h1>
|
|
|
|
<% if @errors %>
|
|
<% @errors.each do |error| %>
|
|
<% if error.attribute == :rating and error.type == :blank %>
|
|
<p class="error"><%= _("Missing rating for candidate <i>%{name}</i>." % { name: error.candidate.name }) %></p>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% if @vote.expire_on %>
|
|
<p><%= _("Closing date: %{date}" % { date: format_date_and_time(@vote.expire_on) }) %></p>
|
|
<% end %>
|
|
|
|
<%= markdown(@vote.description) %>
|
|
|
|
<h2><%= _("Your ratings") %></h2>
|
|
|
|
<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 } %>
|
|
<% if rating
|
|
value = rating.value
|
|
elsif @params[candidate.id.to_s]
|
|
value = params[candidate.id.to_s].to_i
|
|
else
|
|
value = 0
|
|
end %>
|
|
<li>
|
|
<p><b><%= candidate.name %></b></p>
|
|
<%= markdown(candidate.description) %>
|
|
<ul>
|
|
<% settings.values.reverse.each do |v| %>
|
|
<li><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] %>" class="value-<%= v[:id] %>"><%= v[:label] %></label></li>
|
|
<% end %>
|
|
</ul>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
<button type="submit"><%= _("Save") %></button>
|
|
</form>
|
|
|
|
<h2><%= _("Participants") %></h2>
|
|
|
|
<ul>
|
|
<% @vote.ratings.collect { |rating| rating.user }.uniq.each do |user| %>
|
|
<li><%= user.email %></li>
|
|
<% end %>
|
|
</ul>
|
|
|
|
<% unless @vote.organizers.blank? %>
|
|
|
|
<h2><%= _("Organizers") %></h2>
|
|
|
|
<ul>
|
|
<% @vote.organizers.each do |organizer| %>
|
|
<li><%= organizer.user.email %></li>
|
|
<% end %>
|
|
</ul>
|
|
|
|
<% end %>
|
|
|
|
<% if @vote.users.exists?(current_user.id) and @vote.expire_on.nil? %>
|
|
|
|
<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 organizer") %></button>
|
|
</form>
|
|
|
|
<% end %>
|