Allow users to delete dashboard polls

This commit is contained in:
decabeza
2019-05-29 10:45:55 +02:00
parent 6b7c6a2f1f
commit 3855bf26ad
6 changed files with 56 additions and 4 deletions

View File

@@ -35,6 +35,16 @@ class Dashboard::PollsController < Dashboard::BaseController
end
end
def destroy
if ::Poll::Voter.where(poll: poll).any?
redirect_to proposal_dashboard_polls_path(proposal), alert: t("dashboard.polls.poll.unable_notice")
else
poll.destroy
redirect_to proposal_dashboard_polls_path(proposal), notice: t("dashboard.polls.poll.success_notice")
end
end
private
def poll