Compare commits

..

No commits in common. "master" and "livewire-addeed-school-email-domain" have entirely different histories.

20 changed files with 421 additions and 639 deletions

View File

@ -65,14 +65,14 @@ class YearEndCleanup
if (is_array($options)) { if (is_array($options)) {
if (in_array('deleteRooms', $options)) { if (in_array('deleteRooms', $options)) {
DB::table('auditions')->update(['room_id' => 0]); DB::table('auditions')->update(['room_id' => null]);
DB::table('auditions')->update(['order_in_room' => '0']); DB::table('auditions')->update(['order_in_room' => '0']);
DB::table('room_user')->truncate(); DB::table('room_user')->truncate();
DB::table('rooms')->where('id', '>', 0)->delete(); DB::table('rooms')->delete();
} }
if (in_array('removeAuditionsFromRoom', $options)) { if (in_array('removeAuditionsFromRoom', $options)) {
DB::table('auditions')->update(['room_id' => 0]); DB::table('auditions')->update(['room_id' => null]);
DB::table('auditions')->update(['order_in_room' => '0']); DB::table('auditions')->update(['order_in_room' => '0']);
} }

View File

@ -1,41 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Actions\Tabulation\EnterScore;
use App\Models\ScoreSheet;
use Illuminate\Console\Command;
class RecalculateJudgeTotalsCommand extends Command
{
protected $signature = 'audition:recalculate-judge-totals';
protected $description = 'Recalculates total scores for all score sheets for unpubished auditions';
public function handle(): void
{
$this->info('Starting score recalculation...');
$scoreSheets = ScoreSheet::all();
foreach ($scoreSheets as $scoreSheet) {
if ($scoreSheet->entry->audition->hasFlag('seats_published')) {
continue;
}
$this->recalculate($scoreSheet);
}
$this->info('Score recalculation completed successfully.');
}
private function recalculate(ScoreSheet|int $scoreSheet): void
{
if (is_int($scoreSheet)) {
$scoreSheet = ScoreSheet::findOrFail($scoreSheet);
}
$scribe = app()->make(EnterScore::class);
$scoreSubmission = [];
foreach ($scoreSheet->subscores as $subscore) {
$scoreSubmission[$subscore['subscore_id']] = $subscore['score'];
}
$scribe($scoreSheet->judge, $scoreSheet->entry, $scoreSubmission, $scoreSheet);
}
}

View File

@ -8,14 +8,14 @@ use Illuminate\Console\Command;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class RecalculateTotalScores extends Command class RecalculateScores extends Command
{ {
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *
* @var string * @var string
*/ */
protected $signature = 'audition:recalculate-total-scores'; protected $signature = 'audition:recalculate-scores';
/** /**
* The console command description. * The console command description.

View File

@ -28,14 +28,10 @@ class PrintCards extends Controller
public function print(\App\Actions\Print\PrintCards $printer) public function print(\App\Actions\Print\PrintCards $printer)
{ {
//dump(request()->all()); //dump(request()->all());
// if (request()->audition == null) { if (request()->audition == null) {
// return redirect()->back()->with('error', 'You must specify at least one audition'); return redirect()->back()->with('error', 'You must specify at least one audition');
// }
if (request()->audition) {
$selectedAuditionIds = array_keys(request()->audition);
} else {
$selectedAuditionIds = [];
} }
$selectedAuditionIds = array_keys(request()->audition);
$cardQuery = Entry::whereIn('audition_id', $selectedAuditionIds); $cardQuery = Entry::whereIn('audition_id', $selectedAuditionIds);
// Process Filters // Process Filters

View File

@ -110,10 +110,6 @@ class ScoringGuideController extends Controller
'Cannot update a subscore for a different scoring guide'); 'Cannot update a subscore for a different scoring guide');
} }
$validateData = $validateData = $request->validated(); $validateData = $validateData = $request->validated();
if (! auditionSetting('advanceTo')) {
$validateData['for_advance'] = 0;
$validateData['for_seating'] = 1;
}
$subscore->update([ $subscore->update([
'name' => $validateData['name'], 'name' => $validateData['name'],

View File

@ -3,7 +3,6 @@
namespace App\Http\Controllers\Judging; namespace App\Http\Controllers\Judging;
use App\Actions\Tabulation\EnterScore; use App\Actions\Tabulation\EnterScore;
use App\Exceptions\AuditionAdminException;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Audition; use App\Models\Audition;
use App\Models\Entry; use App\Models\Entry;
@ -101,11 +100,7 @@ class JudgingController extends Controller
// Enter the score // Enter the score
/** @noinspection PhpUnhandledExceptionInspection */ /** @noinspection PhpUnhandledExceptionInspection */
try {
$enterScore(Auth::user(), $entry, $validatedData['score']); $enterScore(Auth::user(), $entry, $validatedData['score']);
} catch (AuditionAdminException $e) {
return redirect()->back()->with('error', $e->getMessage());
}
// Deal with an advancement vote if needed // Deal with an advancement vote if needed
$this->advancementVote($request, $entry); $this->advancementVote($request, $entry);

View File

@ -45,15 +45,7 @@ class PrelimJudgingController extends Controller
$oldSheet = PrelimScoreSheet::where('user_id', Auth::id())->where('entry_id', $oldSheet = PrelimScoreSheet::where('user_id', Auth::id())->where('entry_id',
$entry->id)->value('subscores') ?? null; $entry->id)->value('subscores') ?? null;
if ($oldSheet) { return view('judging.prelim_entry_form', compact('entry', 'oldSheet'));
$formRoute = 'update.savePrelimScoreSheet';
$formMethod = 'PATCH';
} else {
$formRoute = 'judging.savePrelimScoreSheet';
$formMethod = 'POST';
}
return view('judging.prelim_entry_form', compact('entry', 'oldSheet', 'formRoute', 'formMethod'));
} }
/** /**

View File

@ -81,7 +81,7 @@ class AdvancementController extends Controller
return $entry->hasFlag('no_show'); return $entry->hasFlag('no_show');
}); });
$scoringComplete = $audition->entries->where('for_advancement', true)->every(function ($entry) { $scoringComplete = $audition->entries->where('for_advancement, true')->every(function ($entry) {
return $entry->totalScore || $entry->hasFlag('no_show'); return $entry->totalScore || $entry->hasFlag('no_show');
}); });

View File

@ -78,7 +78,7 @@ return [
'url' => env('LOG_SLACK_WEBHOOK_URL'), 'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'debug'), 'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true, 'replace_placeholders' => true,
], ],

735
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,6 @@
</include> </include>
</source> </source>
<php> <php>
<ini name="memory_limit" value="512M"/>
<env name="APP_ENV" value="testing"/> <env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/> <env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/> <env name="BCRYPT_ROUNDS" value="4"/>

View File

@ -13,7 +13,8 @@
<tr> <tr>
<x-table.th>Name</x-table.th> <x-table.th>Name</x-table.th>
<x-table.th>School</x-table.th> <x-table.th>School</x-table.th>
<x-table.th>Cell Phone<br />Email</x-table.th> <x-table.th>Email</x-table.th>
<x-table.th>Cell Phone</x-table.th>
<x-table.th>Judging Preference</x-table.th> <x-table.th>Judging Preference</x-table.th>
<x-table.th>Privileges</x-table.th> <x-table.th>Privileges</x-table.th>
</tr> </tr>
@ -21,16 +22,10 @@
<x-table.body> <x-table.body>
@foreach($users as $user) @foreach($users as $user)
<tr class="hover:bg-gray-50"> <tr class="hover:bg-gray-50">
<x-table.td> <x-table.td><a href="{{ route('admin.users.edit',$user) }}">{{ $user->full_name(true) }}</a>{{ $user->hasFlag('head_director') ? ' *':'' }}</x-table.td>
<a href="{{ route('admin.users.edit',$user) }}">{{ $user->full_name(true) }}</a>
{{ $user->hasFlag('head_director') ? ' *':'' }}
@if(! $user->email_verified_at)
<p class="text-xs font-light">Unverified Account</p>
@endif
</x-table.td>
<x-table.td>{{ $user->has_school() ? $user->school->name : ' ' }}</x-table.td> <x-table.td>{{ $user->has_school() ? $user->school->name : ' ' }}</x-table.td>
<x-table.td>{{ $user->cell_phone }}<br/>{{ $user->email }}</x-table.td> <x-table.td>{{ $user->email }}</x-table.td>
<x-table.td>{{ $user->cell_phone }}</x-table.td>
<x-table.td>{{ $user->judging_preference }}</x-table.td> <x-table.td>{{ $user->judging_preference }}</x-table.td>
<x-table.td> <x-table.td>
@if($user->is_admin) @if($user->is_admin)

View File

@ -2,7 +2,7 @@
<x-layout.page-header>Year End Reset</x-layout.page-header> <x-layout.page-header>Year End Reset</x-layout.page-header>
<x-card.card class="mt-5 max-w-xl m-auto"> <x-card.card class="mt-5 max-w-xl m-auto">
<x-card.heading>Reset Options</x-card.heading> <x-card.heading>Reset Options</x-card.heading>
<x-form.form action="{{ route('admin.execute_year_end_procedures') }}"> <x-form.form action="{{ route('admin.year_end_procedures') }}">
<x-form.checkbox name="options[]" label="Delete Rooms" value="deleteRooms" /> <x-form.checkbox name="options[]" label="Delete Rooms" value="deleteRooms" />
<x-form.checkbox name="options[]" label="Remove Auditions From Rooms" value="removeAuditionsFromRoom" /> <x-form.checkbox name="options[]" label="Remove Auditions From Rooms" value="removeAuditionsFromRoom" />
<x-form.checkbox name="options[]" label="Unassign Judges" value="unassignJudges" /> <x-form.checkbox name="options[]" label="Unassign Judges" value="unassignJudges" />

View File

@ -29,14 +29,14 @@
<option value="user">Director</option> <option value="user">Director</option>
<option value="admin" selected>Admin</option> <option value="admin" selected>Admin</option>
</x-form.select> </x-form.select>
<x-layout.navbar.nav-link href="/admin" :active="request()->is('admin')">Dashboard</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin" :active="request()->is('admin')">Dashboard</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin/users" :active="request()->is('admin/users')">Users</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin/users" :active="request()->is('admin/users')">Users</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin/schools" :active="request()->is('admin/schools')">Schools</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin/schools" :active="request()->is('admin/schools')">Schools</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin/students" :active="request()->is('admin/students')">Students</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin/students" :active="request()->is('admin/students')">Students</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin/entries" :active="request()->is('admin/entries')">Entries</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin/entries" :active="request()->is('admin/entries')">Entries</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin/auditions" :active="request()->is('admin/auditions')">Auditions</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin/auditions" :active="request()->is('admin/auditions')">Auditions</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin/scoring" :active="request()->is('admin/scoring')">Scoring</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin/scoring" :active="request()->is('admin/scoring')">Scoring</x-layout.nav-link>
<x-layout.navbar.nav-link href="/admin/rooms" :active="request()->is('admin/rooms')">Rooms</x-layout.navbar.nav-link> <x-layout.nav-link href="/admin/rooms" :active="request()->is('admin/rooms')">Rooms</x-layout.nav-link>
{{-- <a href="/dashboard" class="bg-indigo-700 text-white rounded-md px-3 py-2 text-sm font-medium" aria-current="page">Dashboard</a>--}} {{-- <a href="/dashboard" class="bg-indigo-700 text-white rounded-md px-3 py-2 text-sm font-medium" aria-current="page">Dashboard</a>--}}
{{-- <a href="/students" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 rounded-md px-3 py-2 text-sm font-medium">Students</a>--}} {{-- <a href="/students" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 rounded-md px-3 py-2 text-sm font-medium">Students</a>--}}

View File

@ -15,9 +15,11 @@
</ul> </ul>
</x-slot:subheading> </x-slot:subheading>
</x-card.heading> </x-card.heading>
<x-form.form method="POST" action="{{ route($formRoute, $entry) }}"> <x-form.form method="POST" action="{{ route('judging.savePrelimScoreSheet', $entry) }}">
@method($formMethod) @if($oldSheet)
{{-- if there are existing scores, make this a patch request --}}
@method('PATCH')
@endif
<x-card.list.body class="mt-1"> <x-card.list.body class="mt-1">
@foreach($entry->audition->prelimDefinition->scoringGuide->subscores()->orderBy('display_order')->get() as $subscore) @foreach($entry->audition->prelimDefinition->scoringGuide->subscores()->orderBy('display_order')->get() as $subscore)
@php @php

View File

@ -38,7 +38,7 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
// Year-end procedures // Year-end procedures
Route::get('/year_end_procedures', [YearEndResetController::class, 'index'])->name('admin.year_end_procedures'); Route::get('/year_end_procedures', [YearEndResetController::class, 'index'])->name('admin.year_end_procedures');
Route::post('/year_end_procedures', [YearEndResetController::class, 'execute'])->name('admin.execute_year_end_procedures'); Route::post('/year_end_procedures', [YearEndResetController::class, 'execute'])->name('admin.year_end_procedures');
Route::post('/auditions/roomUpdate', [ Route::post('/auditions/roomUpdate', [
AuditionController::class, 'roomUpdate', AuditionController::class, 'roomUpdate',

View File

@ -22,7 +22,7 @@ Route::middleware(['auth', 'verified', CheckIfCanJudge::class])->prefix('judging
Route::get('/{prelimDefinition}', 'prelimEntryList')->name('judging.prelimEntryList'); Route::get('/{prelimDefinition}', 'prelimEntryList')->name('judging.prelimEntryList');
route::get('/enterScore/{entry}', 'prelimScoreEntryForm')->name('judging.prelimScoreEntryForm'); route::get('/enterScore/{entry}', 'prelimScoreEntryForm')->name('judging.prelimScoreEntryForm');
route::post('/enterScore/{entry}', 'savePrelimScoreSheet')->name('judging.savePrelimScoreSheet'); route::post('/enterScore/{entry}', 'savePrelimScoreSheet')->name('judging.savePrelimScoreSheet');
route::patch('/enterScore/{entry}', 'updatePrelimScoreSheet')->name('judging.updatePrelimScoreSheet'); route::patch('/enterScore/{entry}', 'updatePrelimScoreSheet')->name('judging.savePrelimScoreSheet');
}); });
// Bonus score judging routes // Bonus score judging routes

View File

@ -25,7 +25,7 @@ it('calls the YearEndCleanup action', function () {
$mock->shouldReceive('__invoke')->once(); $mock->shouldReceive('__invoke')->once();
app()->instance(YearEndCleanup::class, $mock); app()->instance(YearEndCleanup::class, $mock);
actAsAdmin(); actAsAdmin();
$response = $this->post(route('admin.execute_year_end_procedures')); $response = $this->post(route('admin.year_end_procedures'));
$response->assertRedirect(route('dashboard')) $response->assertRedirect(route('dashboard'))
->with('success', 'Year end cleanup completed. '); ->with('success', 'Year end cleanup completed. ');
}); });

View File

@ -1,5 +1,6 @@
<?php <?php
use App\Models\Entry;
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
@ -14,8 +15,183 @@ describe('index method', function () {
$response = $this->get(route('monitor.index')); $response = $this->get(route('monitor.index'));
$response->assertForbidden(); $response->assertForbidden();
}); });
it('needs additional tests written', function () {
// TODO: Write tests for new monitor pabe it('presents a form to choose an entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
actingAs($user);
$response = $this->get(route('monitor.index'));
$response->assertOk()
->assertViewIs('tabulation.choose_entry');
});
});
describe('method flagForm is a form to decide what type of flag to put on an entry', function () {
it('only allows those assigned to monitor to access this page', function () {
$user = User::factory()->create();
actingAs($user);
$response = $this->post(route('monitor.enterFlag'));
$response->assertStatus(403);
});
it('wont add flags to an entry in an audition with published seats', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('seats_published');
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with published advancement', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('advancement_published');
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with scores', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
DB::table('score_sheets')->insert([
'user_id' => $user->id,
'entry_id' => $entry->id,
'subscores' => json_encode([12, 3, 5]),
'seating_total' => 1,
'advancement_total' => 1,
]);
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('That entry has existing scores');
});
it('displays a form to choose a flag for the entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.enterFlag'), ['entry_id' => $entry->id]);
$response->assertOk()
->assertViewIs('monitor_entry_flag_form');
});
});
describe('method storeFlag stores the flag and returns to the select entry form', function () {
it('only allows those assigned to monitor to access this page', function () {
$user = User::factory()->create();
$entry = Entry::factory()->create();
actingAs($user);
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertForbidden();
});
it('wont add flags to an entry in an audition with published seats', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('seats_published');
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with published advancement', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->audition->addFlag('advancement_published');
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Cannot set flags while results are published');
});
it('wont add flags to an entry in an audition with scores', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
DB::table('score_sheets')->insert([
'user_id' => $user->id,
'entry_id' => $entry->id,
'subscores' => json_encode([12, 3, 5]),
'seating_total' => 1,
'advancement_total' => 1,
]);
$response = $this->post(route('monitor.storeFlag', $entry), ['flag' => 'no_show']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('That entry has existing scores');
});
it('wont add a bogus flag', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'nonsense']);
$response->assertRedirect(route('monitor.index'))
->assertSessionHas('error');
expect($response->getSession()->get('error'))->toBe('Invalid action requested');
});
it('can add a failed-prelim tag to an entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'failed-prelim']);
$response->assertRedirect(route('monitor.index'));
$entry->refresh();
expect($entry->hasFlag('failed_prelim'))->toBeTrue();
});
it('can add a no-show tag to an entry', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'no-show']);
$response->assertRedirect(route('monitor.index'));
$entry->refresh();
expect($entry->hasFlag('no_show'))->toBeTrue();
});
it('can clear flags', function () {
$user = User::factory()->create();
$user->addFlag('monitor');
$user->refresh();
actingAs($user);
$entry = Entry::factory()->create();
$entry->addFlag('no_show');
$entry->refresh();
expect($entry->hasFlag('no_show'))->toBeTrue();
$response = $this->post(route('monitor.storeFlag', $entry), ['action' => 'clear']);
$response->assertRedirect(route('monitor.index'));
$entry->refresh();
expect($entry->hasFlag('no_show'))->toBeFalse();
});
}); });
});

View File

@ -2,11 +2,6 @@ import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin'; import laravel from 'laravel-vite-plugin';
export default defineConfig({ export default defineConfig({
server: {
cors: {
origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|auditionadmin\.test|127\.0\.0\.1|\[::1\])(?::\d+)?$/,
}
},
plugins: [ plugins: [
laravel({ laravel({
input: ['resources/css/app.css', 'resources/js/app.js'], input: ['resources/css/app.css', 'resources/js/app.js'],