Don't let judges modify scores for published auditions
This commit is contained in:
parent
749af22aad
commit
a9fdc1a7f0
|
|
@ -9,6 +9,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Tests\Feature\Models\ScoreSheet;
|
||||
|
||||
use function compact;
|
||||
use function redirect;
|
||||
use function url;
|
||||
|
|
@ -31,8 +32,9 @@ class JudgingController extends Controller
|
|||
$subscores = $audition->scoringGuide->subscores()->orderBy('display_order')->get();
|
||||
|
||||
$votes = JudgeAdvancementVote::where('user_id', Auth::id())->get();
|
||||
$published = $audition->hasFlag('advancement_published') || $audition->hasFlag('seats_published');
|
||||
|
||||
return view('judging.audition_entry_list', compact('audition', 'entries', 'subscores', 'votes'));
|
||||
return view('judging.audition_entry_list', compact('audition', 'entries', 'subscores', 'votes', 'published'));
|
||||
}
|
||||
|
||||
public function entryScoreSheet(Request $request, Entry $entry)
|
||||
|
|
@ -40,6 +42,9 @@ class JudgingController extends Controller
|
|||
if ($request->user()->cannot('judge', $entry->audition)) {
|
||||
return redirect()->route('judging.index')->with('error', 'You are not assigned to judge this entry');
|
||||
}
|
||||
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
|
||||
return redirect()->route('judging.auditionEntryList', $entry->audition)->with('error', 'Scores for entries in published auditions cannot be modified');
|
||||
}
|
||||
$oldSheet = ScoreSheet::where('user_id', Auth::id())->where('entry_id', $entry->id)->value('subscores') ?? null;
|
||||
$oldVote = JudgeAdvancementVote::where('user_id', Auth::id())->where('entry_id', $entry->id)->first();
|
||||
$oldVote = $oldVote ? $oldVote->vote : 'novote';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,12 @@
|
|||
<x-layout.app>
|
||||
<x-slot:page_title>Judging Dashboard</x-slot:page_title>
|
||||
<x-card.card>
|
||||
<x-card.heading>{{ $audition->name }}</x-card.heading>
|
||||
<x-card.heading>
|
||||
{{ $audition->name }}
|
||||
@if($published)
|
||||
<x-slot:subheading class="text-red-500">Results are published. Scores cannot be changed.</x-slot:subheading>
|
||||
@endif
|
||||
</x-card.heading>
|
||||
<x-table.table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -20,9 +25,13 @@
|
|||
@foreach($entries as $entry)
|
||||
<tr>
|
||||
<x-table.td>
|
||||
<a href="{{ route('judging.entryScoreSheet',$entry) }}">
|
||||
@if(! $published)
|
||||
<a href="{{ route('judging.entryScoreSheet',$entry) }}">
|
||||
@endif
|
||||
{{ $audition->name }} {{ $entry->draw_number }}
|
||||
</a>
|
||||
@if(! $published)
|
||||
</a>
|
||||
@endif
|
||||
</x-table.td>
|
||||
@foreach($subscores as $subscore)
|
||||
<x-table.td>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
|||
use Illuminate\Support\Facades\Artisan;
|
||||
use Tests\Feature\Models\ScoreSheet;
|
||||
|
||||
use function Pest\Laravel\actingAs;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
|
|
@ -110,10 +112,19 @@ test('it shows scores previously entered', function () {
|
|||
});
|
||||
it('indicates when an audition has published seats or advancement', function () {
|
||||
// Arrange
|
||||
$seatsPublishedAudition = Audition::factory()->create();
|
||||
$advancePublishedAudition = Audition::factory()->create();
|
||||
$seatsPublishedAudition->addFlag('seats_published');
|
||||
$advancePublishedAudition->addFlag('advancement_published');
|
||||
// Act & Assert
|
||||
|
||||
$this->audition->addFlag('seats_published');
|
||||
actingAs($this->user);
|
||||
// Act
|
||||
$response = $this->get(route('judging.auditionEntryList', $this->audition));
|
||||
// Assert
|
||||
$response->assertOk()
|
||||
->assertSee('Results are published. Scores cannot be changed.');
|
||||
$this->audition->removeFlag('seats_published');
|
||||
$response = $this->get(route('judging.auditionEntryList', $this->audition));
|
||||
$response->assertOk()
|
||||
->assertDontSee('Results are published. Scores cannot be changed.');
|
||||
$this->audition->addFlag('advancement_published');
|
||||
$response = $this->get(route('judging.auditionEntryList', $this->audition));
|
||||
$response->assertOk()
|
||||
->assertSee('Results are published. Scores cannot be changed.');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,3 +118,25 @@ it('allows an assigned judge to enter scores', function () {
|
|||
'td', $arrayToTest[4], '/td',
|
||||
]);
|
||||
});
|
||||
it('redirects if seats are published', function () {
|
||||
// Arrange
|
||||
$this->entries->first()->audition->addFlag('seats_published');
|
||||
$this->actingAs($this->user);
|
||||
// Act
|
||||
$response = $this->get(route('judging.entryScoreSheet', $this->entries->first()));
|
||||
// Assert
|
||||
$response->assertRedirect(route('judging.auditionEntryList', $this->entries[0]->audition))
|
||||
->assertSessionHas('error', 'Scores for entries in published auditions cannot be modified');
|
||||
|
||||
});
|
||||
it('redirects if advancement is published', function () {
|
||||
// Arrange
|
||||
$this->entries->first()->audition->addFlag('advancement_published');
|
||||
$this->actingAs($this->user);
|
||||
// Act
|
||||
$response = $this->get(route('judging.entryScoreSheet', $this->entries->first()));
|
||||
// Assert
|
||||
$response->assertRedirect(route('judging.auditionEntryList', $this->entries[0]->audition))
|
||||
->assertSessionHas('error', 'Scores for entries in published auditions cannot be modified');
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue