From 62b1998ec6ccbb4e9e5571ae044d1bc4deb4883d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Fri, 20 Oct 2017 18:45:34 +0200 Subject: [PATCH] Added `results_enabled` and `stats_enabled` to Poll admin form --- app/controllers/admin/poll/polls_controller.rb | 7 ++++--- app/models/poll.rb | 8 ++++++++ app/views/admin/poll/polls/_form.html.erb | 9 +++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 5103275fb..b146f66cc 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -54,9 +54,10 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController end def poll_params - params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description, - geozone_ids: [], - image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) + params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, + :summary, :description, :results_enabled,:stats_enabled, + geozone_ids: [], + image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) end def search_params diff --git a/app/models/poll.rb b/app/models/poll.rb index 27125d8a1..e1a1c2754 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -90,4 +90,12 @@ class Poll < ActiveRecord::Base end end + def results_enabled? + results_enabled + end + + def stats_enabled? + stats_enabled + end + end diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb index aff19d9d7..21f1a97f3 100644 --- a/app/views/admin/poll/polls/_form.html.erb +++ b/app/views/admin/poll/polls/_form.html.erb @@ -53,6 +53,15 @@ +
+
+ <%= t('admin.polls.new.show_results_and_stats') %> + <%= f.check_box :results_enabled, checked: @poll.results_enabled?, label: t('admin.polls.new.show_results') %> + <%= f.check_box :stats_enabled, checked: @poll.stats_enabled?, label: t('admin.polls.new.show_stats') %> +

<%= t('admin.polls.new.results_and_stats_reminder') %> +

+
+
<%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"),