From 9263cf2f806e1e04f798cc8fe708af94b5852460 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Sun, 14 Jul 2024 22:14:02 -0500 Subject: [PATCH] Add delete score buttons and edit scores button to edit entry screen. Closes #15 --- resources/views/admin/entries/edit.blade.php | 33 +++++++++++++------ routes/admin.php | 2 -- routes/tabulation.php | 3 +- tests/Feature/Pages/Admin/EntriesEditTest.php | 18 ++++++++++ 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/resources/views/admin/entries/edit.blade.php b/resources/views/admin/entries/edit.blade.php index 08d01c1..f34193a 100644 --- a/resources/views/admin/entries/edit.blade.php +++ b/resources/views/admin/entries/edit.blade.php @@ -67,36 +67,49 @@ - Scores + + Scores + + Edit Scores + +
@foreach($scores as $score) @php($score->isValid())
-

{{ $score->judge->full_name() }}

+
+ {{ $score->judge->full_name() }} + + + Confirm you would like to delete the {{ $score->entry->audition->name }} score for {{ $score->entry->student->full_name() }} by {{ $score->judge->full_name() }}. + + +
@foreach($score->subscores as $subscore)

- {{$subscore['subscore_name'] }} + {{$subscore['subscore_name'] }} {{$subscore['score']}}

@endforeach

- {{ auditionSetting('auditionAbbreviation') }} Total + {{ auditionSetting('auditionAbbreviation') }} Total {{ $score->totalScore('seating')[0] }}

@if( auditionSetting('advanceTo'))

- {{ auditionSetting('advanceTo') }} Total + {{ auditionSetting('advanceTo') }} Total {{ $score->totalScore('advancement')[0] }}

@endif @if(! $score->isValid()) -
- @csrf - @method('DELETE') - +
+

This score is invalid

+
@endif
@endforeach diff --git a/routes/admin.php b/routes/admin.php index 918324d..f0f9c55 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -68,8 +68,6 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')-> Route::patch('/{audition}', 'update')->name('admin.auditions.update'); Route::post('/reorder', 'reorder')->name('admin.auditions.reorder'); Route::delete('/{audition}', 'destroy')->name('admin.auditions.destroy'); - #Route::get('/run_draw', 'prepareDraw')->name('admin.auditions.prepareDraw'); - #Route::post('/run_draw', 'runDraw')->name('admin.auditions.runDraw'); }); // Admin Audition Draw Routes diff --git a/routes/tabulation.php b/routes/tabulation.php index 2bde4eb..99f9d98 100644 --- a/routes/tabulation.php +++ b/routes/tabulation.php @@ -19,8 +19,7 @@ Route::middleware(['auth', 'verified', CheckIfCanTab::class])->group(function () Route::get('/choose_entry', 'chooseEntry')->name('scores.chooseEntry'); Route::get('/entry', 'entryScoreSheet')->name('scores.entryScoreSheet'); Route::post('/entry/{entry}', 'saveEntryScoreSheet')->name('scores.saveEntryScoreSheet'); - Route::delete('/{score}', - [ScoreController::class, 'destroyScore'])->name('scores.destroy'); + Route::delete('/{score}', 'destroyScore')->name('scores.destroy'); }); // Entry Flagging diff --git a/tests/Feature/Pages/Admin/EntriesEditTest.php b/tests/Feature/Pages/Admin/EntriesEditTest.php index 6bbb19e..e9b3fcb 100644 --- a/tests/Feature/Pages/Admin/EntriesEditTest.php +++ b/tests/Feature/Pages/Admin/EntriesEditTest.php @@ -3,6 +3,7 @@ use App\Models\Audition; use App\Models\Entry; use App\Models\Room; +use App\Models\ScoreSheet; use App\Models\ScoringGuide; use App\Models\SubscoreDefinition; use App\Models\User; @@ -220,6 +221,23 @@ it('displays scores', function () { $response->assertSee($subscore->name); } }); +it('has a link to delete scores', function() { + // Arrange + $sg = ScoringGuide::factory()->create(); + SubscoreDefinition::factory()->count(5)->create(['scoring_guide_id' => $sg->id]); + $room = Room::factory()->create(); + $judge = User::factory()->create(); + $room->addJudge($judge); + $audition = Audition::factory()->create(['room_id' => $room->id, 'scoring_guide_id' => $sg->id]); + $entry = Entry::factory()->create(['audition_id' => $audition->id]); + // Run the ScoreAllAuditions seeder + Artisan::call('db:seed', ['--class' => 'ScoreAllAuditions']); + // Act & Assert + $scoreSheet = ScoreSheet::where('entry_id', $entry->id)->first(); + actAsAdmin(); + $response = get(route('admin.entries.edit', $entry)) + ->assertSee(route('scores.destroy', ['score'=>$scoreSheet])); +}); // Delete tests it('does not allow a normal user to delete an entry', function () { -- 2.39.5