From da30b0240545f1269799289df8cbb76534136261 Mon Sep 17 00:00:00 2001 From: ricola Date: Fri, 9 Jan 2026 15:35:33 -0600 Subject: [PATCH 1/8] Add feedback when voting --- vedia.rb | 4 ++-- views/votes.erb | 5 +++++ views/votes_show_open.erb | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) 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 @@