From b94e0fada5be63e49d5423846a686dfb6e3b13b0 Mon Sep 17 00:00:00 2001 From: blt950 Date: Sat, 6 Mar 2021 17:01:40 +0100 Subject: [PATCH] Fixed so moderators can publish reports of trainings without being assigned #282 --- app/Policies/TrainingExaminationPolicy.php | 9 ++------- app/Policies/TrainingPolicy.php | 4 ++-- app/Policies/TrainingReportPolicy.php | 9 ++------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app/Policies/TrainingExaminationPolicy.php b/app/Policies/TrainingExaminationPolicy.php index 6708b1f86..1c8a1b81d 100644 --- a/app/Policies/TrainingExaminationPolicy.php +++ b/app/Policies/TrainingExaminationPolicy.php @@ -31,13 +31,8 @@ public function view(User $user, TrainingExamination $examination) */ public function create(User $user) { - if (($key = session()->get('onetimekey')) != null) { - $link = OneTimeLink::where('key', $key)->get()->first(); - - return $link != null && $user->isMentorOrAbove($link->training->area); - } - - return $user->isMentorOrAbove(); + // We use TrainingPolicy-createExamination instead, so this should always return false. + return false; } /** diff --git a/app/Policies/TrainingPolicy.php b/app/Policies/TrainingPolicy.php index 447969d08..166f686f9 100644 --- a/app/Policies/TrainingPolicy.php +++ b/app/Policies/TrainingPolicy.php @@ -122,11 +122,11 @@ public function viewReports(User $user, Training $training) public function createReport(User $user, Training $training) { if (($link = $this->getOneTimeLink($training)) != null) { - return $user->isMentor($link->training->area); + return $user->isModerator($link->training->area) || $user->isMentor($link->training->area); } // Check if mentor is mentoring area, not filling their own training and the training is in progress - return $training->mentors->contains($user) && $user->isNot($training->user); + return $user->isModerator($training->area) || ($training->mentors->contains($user) && $user->isNot($training->user)); } public function createExamination(User $user, Training $training) diff --git a/app/Policies/TrainingReportPolicy.php b/app/Policies/TrainingReportPolicy.php index 28311936e..0b187a99c 100644 --- a/app/Policies/TrainingReportPolicy.php +++ b/app/Policies/TrainingReportPolicy.php @@ -36,13 +36,8 @@ public function view(User $user, TrainingReport $trainingReport) */ public function create(User $user) { - if (($key = session()->get('onetimekey')) != null) { - $link = OneTimeLink::where('key', $key)->get()->first(); - - return $link != null && $user->isMentor($link->training->area); - } - - return $user->isMentor(); + // We use TrainingPolicy-createReport instead, so this should always return false. + return false; } /**