diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index aa93581cc..708f68abb 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -3,8 +3,6 @@ class PollsController < ApplicationController load_and_authorize_resource - before_filter :set_poll, only: [:stats, :results] - has_filters %w{current expired incoming} has_orders %w{most_voted newest oldest}, only: :show @@ -36,10 +34,4 @@ class PollsController < ApplicationController def results end - private - - def set_poll - @poll = Poll.find(params[:poll_id]) - end - end diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index 32f948a5a..dd692c269 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -7,8 +7,12 @@ module Abilities can [:read, :map, :summary, :share], Proposal can :read, Comment can :read, Poll - cannot :results, Poll, results_enabled: false - cannot :stats, Poll, stats_enabled: false + can :results, Poll do |poll| + poll.expired? && poll.results_enabled? + end + can :stats, Poll do |poll| + poll.expired? && poll.stats_enabled? + end can :read, Poll::Question can [:read, :welcome], Budget can :read, SpendingProposal diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index 529e9a99e..93174e157 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -19,11 +19,27 @@
<% if poll.questions.count == 1 %> <% poll.questions.each do |question| %> -