Require at least 2 candidates to open a vote
This commit is contained in:
parent
440013890e
commit
dc01cb61ad
2 changed files with 9 additions and 2 deletions
|
|
@ -57,7 +57,12 @@
|
||||||
<h3><%= _("Actions for organizers") %></h2>
|
<h3><%= _("Actions for organizers") %></h2>
|
||||||
|
|
||||||
<form action="/votes/<%= @vote.secure_id %>/open" method="post">
|
<form action="/votes/<%= @vote.secure_id %>/open" method="post">
|
||||||
|
<% if @vote.candidates.length < 2 %>
|
||||||
|
<button type="submit" disabled><%= _("Open vote to participants") %></button>
|
||||||
|
<p><%= _("Add at least 2 candidates before opening the vote to participants.") %></p>
|
||||||
|
<% else %>
|
||||||
<button type="submit"><%= _("Open vote to participants") %></button>
|
<button type="submit"><%= _("Open vote to participants") %></button>
|
||||||
|
<% end %>
|
||||||
</form>
|
</form>
|
||||||
<form action="/votes/<%= @vote.secure_id %>/delete" method="post">
|
<form action="/votes/<%= @vote.secure_id %>/delete" method="post">
|
||||||
<button type="submit"><%= _("Delete vote") %></button>
|
<button type="submit"><%= _("Delete vote") %></button>
|
||||||
|
|
|
||||||
6
vote.rb
6
vote.rb
|
|
@ -200,8 +200,10 @@ post '/votes/:id/open' do
|
||||||
find_vote
|
find_vote
|
||||||
require_organizer
|
require_organizer
|
||||||
require_draft_vote
|
require_draft_vote
|
||||||
@vote.state = 'open'
|
if not @vote.candidates.length < 2
|
||||||
@vote.save
|
@vote.state = 'open'
|
||||||
|
@vote.save
|
||||||
|
end
|
||||||
redirect '/votes/' + @vote.secure_id
|
redirect '/votes/' + @vote.secure_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue