Add feedback when voting
This commit is contained in:
parent
a93ae1269b
commit
da30b02405
3 changed files with 16 additions and 2 deletions
4
vedia.rb
4
vedia.rb
|
|
@ -510,15 +510,15 @@ post '/votes/:id/ratings' do
|
||||||
end
|
end
|
||||||
if not @errors.empty?
|
if not @errors.empty?
|
||||||
@params = params
|
@params = params
|
||||||
erb :votes_show_open
|
|
||||||
else
|
else
|
||||||
@vote.candidates.each do |candidate|
|
@vote.candidates.each do |candidate|
|
||||||
rating = Rating.find_or_initialize_by(vote: @vote, user: current_user, candidate: candidate)
|
rating = Rating.find_or_initialize_by(vote: @vote, user: current_user, candidate: candidate)
|
||||||
rating.value = params[candidate.id.to_s]
|
rating.value = params[candidate.id.to_s]
|
||||||
rating.save
|
rating.save
|
||||||
end
|
end
|
||||||
redirect '/votes/' + @vote.secure_id
|
@voted = true
|
||||||
end
|
end
|
||||||
|
erb :votes_show_open
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/votes/:id/organizers' do
|
get '/votes/:id/organizers' do
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@
|
||||||
<% when 'closed' %>
|
<% when 'closed' %>
|
||||||
<SPAN class="badge bg-dark"><%= _("Closed") %></span>
|
<SPAN class="badge bg-dark"><%= _("Closed") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if vote.ratings.find { |rating| rating.user == current_user } %>
|
||||||
|
<span class="badge bg-success"><%= _("Voted") %></span>
|
||||||
|
<% elsif vote.state == 'open' %>
|
||||||
|
<span class="badge bg-danger"><%= _("Not voted") %></span>
|
||||||
|
<% end %>
|
||||||
<% if vote.users.exists?(current_user.id) %>
|
<% if vote.users.exists?(current_user.id) %>
|
||||||
<span class="badge bg-warning text-bg-warning"><%= _("Organizer") %></span>
|
<span class="badge bg-warning text-bg-warning"><%= _("Organizer") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@
|
||||||
<ul class="list-unstyled">
|
<ul class="list-unstyled">
|
||||||
<li>
|
<li>
|
||||||
<span class="badge bg-primary"><%= _("Open") %></span>
|
<span class="badge bg-primary"><%= _("Open") %></span>
|
||||||
|
<% if @vote.ratings.find { |rating| rating.user == current_user } %>
|
||||||
|
<span class="badge bg-success"><%= _("Voted") %></span>
|
||||||
|
<% else %>
|
||||||
|
<span class="badge bg-danger"><%= _("Not voted") %></span>
|
||||||
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% if @vote.expire_on %>
|
<% if @vote.expire_on %>
|
||||||
<li><%= _("Closes on %{date}") % { date: format_date_and_time(@vote.expire_on) } %></li>
|
<li><%= _("Closes on %{date}") % { date: format_date_and_time(@vote.expire_on) } %></li>
|
||||||
|
|
@ -26,6 +31,10 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if @voted %>
|
||||||
|
<p class="alert alert-success mb-4"><%= _("Gràcies per votar!") %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<form action="/votes/<%= @vote.secure_id %>/ratings" method="post" class="mb-5">
|
<form action="/votes/<%= @vote.secure_id %>/ratings" method="post" class="mb-5">
|
||||||
|
|
||||||
<% @vote.candidates.each do |candidate| %>
|
<% @vote.candidates.each do |candidate| %>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue