Skip to content

Commit

Permalink
Fixed so moderators can publish reports of trainings without being as…
Browse files Browse the repository at this point in the history
…signed #282
  • Loading branch information
blt950 committed Mar 6, 2021
1 parent 67163f2 commit b94e0fa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
9 changes: 2 additions & 7 deletions app/Policies/TrainingExaminationPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/Policies/TrainingPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 2 additions & 7 deletions app/Policies/TrainingReportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit b94e0fa

Please sign in to comment.