Create scope by_proposal

Add to active_for class method and to active_resources controller method the new scope by_proposal.
 - Published proposal: display all actions.
 - Draft proposal: only display actions for draft proposals.
This commit is contained in:
taitus
2019-01-08 16:04:49 +01:00
parent 082cc41a1e
commit 9fac661f0c
4 changed files with 137 additions and 31 deletions

View File

@@ -11,8 +11,8 @@ class DashboardController < Dashboard::BaseController
proposal.publish
redirect_to proposal_dashboard_path(proposal), notice: t('proposals.notice.published')
end
def progress
def progress
authorize! :dashboard, proposal
end
@@ -21,9 +21,12 @@ class DashboardController < Dashboard::BaseController
end
private
def active_resources
@active_resources ||= Dashboard::Action.active.resources.order(required_supports: :asc, day_offset: :asc)
@active_resources ||= Dashboard::Action.active
.resources
.by_proposal(proposal)
.order(required_supports: :asc, day_offset: :asc)
end
def course