fix enrollment for the new school-year
Tests / PHPUnit (push) Successful in 1m26s

This commit is contained in:
root
2026-08-07 23:43:31 -04:00
parent b6f3b14e7b
commit 1ef2800f12
66 changed files with 8997 additions and 498 deletions
+16
View File
@@ -24,6 +24,13 @@ class FlagController extends Controller
helper(['url', 'form']);
}
private function assertSchoolYearNameWritable(string $schoolYear): void
{
service('schoolYearWriteGuard')->assertWritable(
service('schoolYearContext')->forYearName($schoolYear)
);
}
public function index()
{
$currentFlagModel = new CurrentFlagModel();
@@ -436,6 +443,13 @@ class FlagController extends Controller
return $this->index();
}
$flagData = $currentFlagModel->find($id);
if (!$flagData) {
session()->setFlashdata('error', 'Incident not found.');
return $this->index();
}
$this->assertSchoolYearNameWritable((string)($flagData['school_year'] ?? ''));
$update = ['flag_state' => $newState];
if ($newState === 'Closed') {
$update['updated_by_closed'] = $userId;
@@ -490,6 +504,7 @@ class FlagController extends Controller
session()->setFlashdata('error', 'Incident not found.');
return redirect()->back();
}
$this->assertSchoolYearNameWritable((string)($flagData['school_year'] ?? ''));
// Proceed only if flag is not closed
if ($flagData['flag_state'] !== 'Closed') {
@@ -537,6 +552,7 @@ class FlagController extends Controller
session()->setFlashdata('error', 'Incident not found.');
return redirect()->back();
}
$this->assertSchoolYearNameWritable((string)($flagData['school_year'] ?? ''));
// Check if the flag is not already canceled
if ($flagData['flag_state'] !== 'Canceled') {