Implements #150
Adds an entry inside moderation section that allows moderators to check pending tasks and mark them as solved.
This commit is contained in:
27
app/controllers/moderation/administrator_tasks_controller.rb
Normal file
27
app/controllers/moderation/administrator_tasks_controller.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Moderation::AdministratorTasksController < Moderation::BaseController
|
||||
helper_method :administrator_task
|
||||
|
||||
def index
|
||||
authorize! :index, AdministratorTask
|
||||
@administrator_tasks = AdministratorTask.pending
|
||||
end
|
||||
|
||||
def edit
|
||||
authorize! :edit, administrator_task
|
||||
end
|
||||
|
||||
def update
|
||||
authorize! :update, administrator_task
|
||||
|
||||
administrator_task.update(user: current_user, executed_at: Time.now)
|
||||
redirect_to moderation_administrator_tasks_path, { flash: { notice: t('.success') } }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def administrator_task
|
||||
@administrator_task ||= AdministratorTask.find(params[:id])
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user