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.
36 lines
839 B
Ruby
36 lines
839 B
Ruby
class DashboardController < Dashboard::BaseController
|
|
helper_method :dashboard_action, :active_resources, :course
|
|
|
|
def show
|
|
authorize! :dashboard, proposal
|
|
end
|
|
|
|
def publish
|
|
authorize! :publish, proposal
|
|
|
|
proposal.publish
|
|
redirect_to proposal_dashboard_path(proposal), notice: t('proposals.notice.published')
|
|
end
|
|
|
|
def progress
|
|
authorize! :dashboard, proposal
|
|
end
|
|
|
|
def community
|
|
authorize! :dashboard, proposal
|
|
end
|
|
|
|
private
|
|
|
|
def active_resources
|
|
@active_resources ||= Dashboard::Action.active
|
|
.resources
|
|
.by_proposal(proposal)
|
|
.order(required_supports: :asc, day_offset: :asc)
|
|
end
|
|
|
|
def course
|
|
@course ||= Dashboard::Action.course_for(proposal)
|
|
end
|
|
end
|