Require being an organizer to edit a draft vote

This commit is contained in:
ricola 2025-04-06 17:04:31 -06:00
parent 97d4df395d
commit a2e41bdc2d
3 changed files with 25 additions and 1 deletions

View file

@ -41,6 +41,8 @@
<% end %>
</ul>
<h3>Add organizer</h3>
<form action="/votes/<%= @vote.secure_id %>/organizers" method="post">
<p>
<label for="email">Email</label>

View file

@ -0,0 +1,18 @@
<h1><%= @vote.title %> (Draft)</h1>
<p><%= @vote.description %></p>
<h2>Organizers</h2>
<ul>
<% @vote.organizers.each do |organizer| %>
<li><%= organizer.user.email %></li>
<% end %>
</ul>
<h2>Candidates</h2>
<% @vote.candidates.each do |candidate| %>
<h3><%= candidate.name %></h3>
<p><%= candidate.description %></p>
<% end %>

View file

@ -116,7 +116,11 @@ get '/votes/:id' do
when "open"
erb :votes_show
when "draft"
erb :votes_edit
if @vote.users.exists?(current_user.id)
erb :votes_edit
else
erb :votes_show_draft
end
when "closed"
erb :votes_results
else