Work on auth for PrelimJudging
This commit is contained in:
parent
88608ea5b4
commit
14b275aa7e
|
|
@ -7,8 +7,11 @@ use App\Models\PrelimDefinition;
|
||||||
|
|
||||||
class PrelimJudgingController extends Controller
|
class PrelimJudgingController extends Controller
|
||||||
{
|
{
|
||||||
public function prelimEntryList(PrelimDefinition $prelimAudition)
|
public function prelimEntryList(PrelimDefinition $prelimDefinition)
|
||||||
{
|
{
|
||||||
dd($prelimAudition);
|
if (auth()->user()->cannot('judge', $prelimDefinition)) {
|
||||||
|
return redirect()->route('dashboard')->with('error', 'You are not assigned to judge that prelim audition.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,11 @@ class PrelimDefinitionPolicy
|
||||||
return $user->is_admin;
|
return $user->is_admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function judge(User $user, PrelimDefinition $prelimDefinition): bool
|
||||||
|
{
|
||||||
|
return $user->judgingAssignments->contains($prelimDefinition->room_id);
|
||||||
|
}
|
||||||
|
|
||||||
public function restore(User $user, PrelimDefinition $prelimDefinition): bool
|
public function restore(User $user, PrelimDefinition $prelimDefinition): bool
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ Route::middleware(['auth', 'verified', CheckIfCanJudge::class])->prefix('judging
|
||||||
|
|
||||||
// Prelim Audition Related Routes
|
// Prelim Audition Related Routes
|
||||||
Route::middleware(['auth', 'verified', CheckIfCanJudge::class])->prefix('judging/prelims')->controller(PrelimJudgingController::class)->group(function () {
|
Route::middleware(['auth', 'verified', CheckIfCanJudge::class])->prefix('judging/prelims')->controller(PrelimJudgingController::class)->group(function () {
|
||||||
Route::get('/{audition}', 'prelimEntryList')->name('judging.prelimEntryList');
|
Route::get('/{prelimDefinition}', 'prelimEntryList')->name('judging.prelimEntryList');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bonus score judging routes
|
// Bonus score judging routes
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Audition;
|
||||||
|
use App\Models\PrelimDefinition;
|
||||||
|
use App\Models\Room;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
describe('PrelimJudgingController:prelimEntryList', function () {
|
||||||
|
it('only allows access to an assigned judge', function () {
|
||||||
|
$judgeUser = User::factory()->create();
|
||||||
|
$notJudgeUser = User::factory()->create();
|
||||||
|
$finalsRoom = Room::factory()->create();
|
||||||
|
$audition = Audition::factory()->create(['room_id' => $finalsRoom->id]);
|
||||||
|
$room = Room::factory()->create();
|
||||||
|
$finalsRoom = Room::factory()->create();
|
||||||
|
$prelimDefinition = PrelimDefinition::create([
|
||||||
|
'audition_id' => $audition->id,
|
||||||
|
'room_id' => $room->id,
|
||||||
|
'scoring_guide_id' => 0,
|
||||||
|
'passing_score' => 75,
|
||||||
|
]);
|
||||||
|
$room->addJudge($judgeUser);
|
||||||
|
$finalsRoom->addJudge($notJudgeUser);
|
||||||
|
|
||||||
|
$this->actingAs($notJudgeUser);
|
||||||
|
$this->get(route('judging.prelimEntryList', $prelimDefinition))
|
||||||
|
->assertRedirect(route('dashboard'))
|
||||||
|
->assertSessionHas('error', 'You are not assigned to judge that prelim audition.');
|
||||||
|
$this->actingAs($judgeUser);
|
||||||
|
$this->get(route('judging.prelimEntryList', $prelimDefinition))
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows all auditions entered in the given audition', function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows scores for previously judged entries', function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has links to enter scores for each entry', function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not allow modifications to an entry that has finals scores', function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue