Add ability to delete prelim auditions. Need to add an observer to log.
This commit is contained in:
parent
cafa1ddf29
commit
674374b6b6
|
|
@ -60,4 +60,11 @@ class PrelimDefinitionController extends Controller
|
||||||
|
|
||||||
return redirect()->route('admin.prelim_definitions.index')->with('success', 'Prelim definition updated');
|
return redirect()->route('admin.prelim_definitions.index')->with('success', 'Prelim definition updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function destroy(PrelimDefinition $prelimDefinition)
|
||||||
|
{
|
||||||
|
$prelimDefinition->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.prelim_definitions.index')->with('success', 'Prelim definition deleted');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@
|
||||||
<x-card.heading>
|
<x-card.heading>
|
||||||
@if($prelim)
|
@if($prelim)
|
||||||
Modify Prelim - {{ $prelim->audition->name }}
|
Modify Prelim - {{ $prelim->audition->name }}
|
||||||
|
<x-slot:right_side>
|
||||||
|
<x-delete-resource-modal title="Delete {{ $prelim->audition->name }} Prelim" action="{{ route('admin.prelim_definitions.destroy', $prelim->id)}}">
|
||||||
|
Confirm that you'd like to delete prelim auditions for {{ $prelim->audition->name }}.
|
||||||
|
{{-- TODO: Block deleting a prelim audition if there are prelim scores --}}
|
||||||
|
</x-delete-resource-modal>
|
||||||
|
</x-slot:right_side>
|
||||||
@else
|
@else
|
||||||
Create Prelim Audition
|
Create Prelim Audition
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<x-card.card>
|
<x-card.card>
|
||||||
<x-card.heading>
|
<x-card.heading>
|
||||||
Preliminary Auditions
|
Preliminary Auditions
|
||||||
|
<x-slot:subheading>Click to edit or delete</x-slot:subheading>
|
||||||
<x-slot:right_side>
|
<x-slot:right_side>
|
||||||
<x-form.button href="{{ route('admin.prelim_definitions.create') }}">Add Prelim</x-form.button>
|
<x-form.button href="{{ route('admin.prelim_definitions.create') }}">Add Prelim</x-form.button>
|
||||||
</x-slot:right_side>
|
</x-slot:right_side>
|
||||||
|
|
@ -18,11 +19,12 @@
|
||||||
</thead>
|
</thead>
|
||||||
<x-table.body>
|
<x-table.body>
|
||||||
@foreach ($prelims as $prelim)
|
@foreach ($prelims as $prelim)
|
||||||
<tr onclick="window.location='{{ route('admin.prelim_definitions.edit', $prelim) }}';" style="cursor:pointer;">
|
<tr onclick="window.location='{{ route('admin.prelim_definitions.edit', $prelim) }}';"
|
||||||
<x-table.td>{{ $prelim->audition->name }}</x-table.td>
|
style="cursor:pointer;">
|
||||||
<x-table.td>{{ $prelim->passing_score }}</x-table.td>
|
<x-table.td>{{ $prelim->audition->name }}</x-table.td>
|
||||||
<x-table.td>{{ $prelim->room->name }}</x-table.td>
|
<x-table.td>{{ $prelim->passing_score }}</x-table.td>
|
||||||
<x-table.td>{{ $prelim->scoringGuide->name }}</x-table.td>
|
<x-table.td>{{ $prelim->room->name }}</x-table.td>
|
||||||
|
<x-table.td>{{ $prelim->scoringGuide->name }}</x-table.td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-table.body>
|
</x-table.body>
|
||||||
|
|
|
||||||
|
|
@ -146,3 +146,30 @@ describe('PrelimDefinitionController::update', function () {
|
||||||
expect($this->prelim->fresh()->passing_score)->toEqual(90);
|
expect($this->prelim->fresh()->passing_score)->toEqual(90);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('PrelimDefinitionController::destroy', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
$this->audition = Audition::factory()->create();
|
||||||
|
$this->prelim = PrelimDefinition::create([
|
||||||
|
'audition_id' => $this->audition->id,
|
||||||
|
'room_id' => 0,
|
||||||
|
'scoring_guide_id' => 0,
|
||||||
|
'passing_score' => 75,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
it('denies access to a non-admin user', function () {
|
||||||
|
$this->delete(route('admin.prelim_definitions.destroy', $this->prelim))->assertRedirect(route('home'));
|
||||||
|
actAsNormal();
|
||||||
|
$this->delete(route('admin.prelim_definitions.destroy', $this->prelim))->assertRedirect(route('dashboard'));
|
||||||
|
actAsTab();
|
||||||
|
$this->delete(route('admin.prelim_definitions.destroy', $this->prelim))->assertRedirect(route('dashboard'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deletes a prelim definition', function () {
|
||||||
|
actAsAdmin();
|
||||||
|
$response = $this->delete(route('admin.prelim_definitions.destroy', $this->prelim));
|
||||||
|
$response
|
||||||
|
->assertRedirect(route('admin.prelim_definitions.index'));
|
||||||
|
expect(PrelimDefinition::count())->toEqual(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue