Add logic for forced application rejection

This commit is contained in:
Miguel Nogueira 2021-11-06 14:52:48 +00:00
parent befc2ebdc6
commit aed473a01a
3 changed files with 25 additions and 10 deletions

View File

@ -47,20 +47,33 @@ class DevToolsController extends Controller
->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get()); ->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get());
} }
/**
* Force an application to be approved.
*/
public function forceApprovalEvent(Request $request) { public function forceApprovalEvent(Request $request) {
$this->singleAuthorise(); $this->singleAuthorise();
$application = Application::find($request->application); $application = Application::find($request->application);
if (! is_null($application)) { event(new ApplicationApprovedEvent($application));
event(new ApplicationApprovedEvent($application));
$request->session()->flash('success', __('Event dispatched! Please check the debug logs for more info')); return redirect()
} else { ->back()
$request->session()->flash('error', __('Application doesn\'t exist!')); ->with('success', __('Event dispatched; Candidate approval sequence initiated.'));
} }
return redirect()->back(); /**
* Force an application to be rejected.
*/
public function forceRejectionEvent(Request $request)
{
$this->singleAuthorise();
$application = Application::findOrFail($request->application);
event(new ApplicationDeniedEvent($application));
return redirect()
->back()
->with('success', __('Event dispatched; Candidate rejection sequence initiated.'));
} }
public function evaluateVotes() { public function evaluateVotes() {

View File

@ -60,7 +60,7 @@
<x-slot name="cardHeader"> <x-slot name="cardHeader">
</x-slot> </x-slot>
<button data-toggle="tooltip" data-placement="top" title="Forces a selected application to be approved, regardless of how many votes it has." type="button" class="btn btn-primary" onclick="$('#confirmForceEventDispatch').modal('show')"><i class="fas fa-bullhorn"></i> Force application approval</button> <button data-toggle="tooltip" data-placement="top" title="Dispatches a specific event for the selected application" type="button" class="btn btn-primary" onclick="$('#confirmForceEventDispatch').modal('show')"><i class="fas fa-bullhorn"></i> Dispatch application event</button>
<form name="evalvotes" method="post" action="{{ route('devForceEvaluateVotes') }}" class="d-inline"> <form name="evalvotes" method="post" action="{{ route('devForceEvaluateVotes') }}" class="d-inline">
@csrf @csrf

View File

@ -311,10 +311,12 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo
->name('devTools'); ->name('devTools');
Route::post('/applications/force-approval', [DevToolsController::class, 'forceApprovalEvent']);
Route::post('/applications/force-approval', [DevToolsController::class, 'forceApprovalEvent']) Route::post('/applications/force-approval', [DevToolsController::class, 'forceApprovalEvent'])
->name('devForceApprovalEvent'); ->name('devForceApprovalEvent');
Route::post('/applications/force-rejection', [DevToolsController::class, 'forceRejectionEvent'])
->name('devForceRejectionEvent');
Route::post('/applications/count-votes', [DevToolsController::class, 'evaluateVotes']) Route::post('/applications/count-votes', [DevToolsController::class, 'evaluateVotes'])
->name('devForceEvaluateVotes'); ->name('devForceEvaluateVotes');