diff --git a/vedia.rb b/vedia.rb index 34c37dd..0fd3cf7 100644 --- a/vedia.rb +++ b/vedia.rb @@ -510,15 +510,15 @@ post '/votes/:id/ratings' do end if not @errors.empty? @params = params - erb :votes_show_open else @vote.candidates.each do |candidate| rating = Rating.find_or_initialize_by(vote: @vote, user: current_user, candidate: candidate) rating.value = params[candidate.id.to_s] rating.save end - redirect '/votes/' + @vote.secure_id + @voted = true end + erb :votes_show_open end get '/votes/:id/organizers' do diff --git a/views/votes.erb b/views/votes.erb index fe1f7a7..1e10aed 100644 --- a/views/votes.erb +++ b/views/votes.erb @@ -14,6 +14,11 @@ <% when 'closed' %> <%= _("Closed") %> <% end %> + <% if vote.ratings.find { |rating| rating.user == current_user } %> + <%= _("Voted") %> + <% elsif vote.state == 'open' %> + <%= _("Not voted") %> + <% end %> <% if vote.users.exists?(current_user.id) %> <%= _("Organizer") %> <% end %> diff --git a/views/votes_show_open.erb b/views/votes_show_open.erb index 1b8cf8d..f69b1bc 100644 --- a/views/votes_show_open.erb +++ b/views/votes_show_open.erb @@ -3,6 +3,11 @@
<%= _("GrĂ cies per votar!") %>
+<% end %> +