Adds an entry inside moderation section that allows moderators to check
pending tasks and mark them as solved.
This commit is contained in:
Juan Salvador Pérez García
2018-06-18 11:39:04 +02:00
parent 83f78b1940
commit 33b3431c70
27 changed files with 384 additions and 9 deletions

View File

@@ -4,7 +4,7 @@
class ProposalsDashboardController < ApplicationController
before_action :authenticate_user!
helper_method :proposal, :proposed_actions
helper_method :proposal, :proposed_actions, :proposal_dashboard_action
respond_to :html
layout 'proposals_dashboard'
@@ -21,12 +21,41 @@ class ProposalsDashboardController < ApplicationController
def execute
authorize! :dashboard, proposal
ProposalExecutedDashboardAction.create(proposal: proposal, proposal_dashboard_action: proposal_dashboard_action, executed_at: Time.now)
redirect_to proposal_dashboard_index_path(proposal.to_param)
end
def new_request
authorize! :dashboard, proposal
@proposal_executed_dashboard_action = ProposalExecutedDashboardAction.new
end
def create_request
authorize! :dashboard, proposal
source_params = proposal_executed_dashboard_action_params.merge(
proposal: proposal,
proposal_dashboard_action: proposal_dashboard_action,
executed_at: Time.now
)
@proposal_executed_dashboard_action = ProposalExecutedDashboardAction.new(source_params)
if @proposal_executed_dashboard_action.save
AdministratorTask.create(source: @proposal_executed_dashboard_action)
redirect_to proposal_dashboard_index_path(proposal.to_param), { flash: { info: t('.success') } }
else
render :new_request
end
end
private
def proposal_executed_dashboard_action_params
params.require(:proposal_executed_dashboard_action).permit(:comments)
end
def proposal_dashboard_action
@proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id])
end