diff --git a/vedia.rb b/vedia.rb index 22b6b61..63d1142 100644 --- a/vedia.rb +++ b/vedia.rb @@ -333,6 +333,30 @@ post '/votes/:id/candidates' do redirect '/votes/' + @vote.secure_id end +get '/votes/:id/candidates/:cid' do + require_login + find_vote + require_organizer + require_draft_vote + find_candidate + require_candidate_in_vote + erb :candidates_edit +end + +post '/votes/:id/candidates/:cid' do + require_login + find_vote + require_organizer + require_draft_vote + find_candidate + require_candidate_in_vote + @candidate.name = params[:name] + @candidate.description = params[:description] + @candidate.save + redirect '/votes/' + @vote.secure_id + erb :candidates_edit +end + post '/votes/:id/candidates/:cid/delete' do require_login find_vote diff --git a/views/candidates_edit.erb b/views/candidates_edit.erb new file mode 100644 index 0000000..16b62d7 --- /dev/null +++ b/views/candidates_edit.erb @@ -0,0 +1,13 @@ +

<%= _("Edit candidate") %>

+ +
+
+ + +
+
+ + +
+ +
diff --git a/views/votes_edit.erb b/views/votes_edit.erb index 03073a5..89585f0 100644 --- a/views/votes_edit.erb +++ b/views/votes_edit.erb @@ -24,6 +24,9 @@

<%= candidate.name %>

<%= markdown(candidate.description) %> +
+ +