Squish Todos
This commit is contained in:
parent
a96e7f4206
commit
4201396d03
|
|
@ -209,5 +209,3 @@ class ScoringGuideController extends Controller
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO need to be able to delete a scoring guide
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
use App\Models\School;
|
use App\Models\School;
|
||||||
use App\Models\Student;
|
use App\Models\Student;
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
use function abort;
|
use function abort;
|
||||||
use function view;
|
use function view;
|
||||||
|
|
||||||
|
|
@ -16,35 +16,43 @@ class StudentController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) abort(403);
|
if (! Auth::user()->is_admin) {
|
||||||
$students = Student::with(['school','entries'])->orderBy('last_name')->orderBy('first_name')->paginate(15);
|
abort(403);
|
||||||
|
}
|
||||||
|
$students = Student::with(['school', 'entries'])->orderBy('last_name')->orderBy('first_name')->paginate(15);
|
||||||
|
|
||||||
return view('admin.students.index', ['students' => $students]);
|
return view('admin.students.index', ['students' => $students]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) abort(403);
|
if (! Auth::user()->is_admin) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
$minGrade = Audition::min('minimum_grade');
|
$minGrade = Audition::min('minimum_grade');
|
||||||
$maxGrade = Audition::max('maximum_grade');
|
$maxGrade = Audition::max('maximum_grade');
|
||||||
$schools = School::orderBy('name')->get();
|
$schools = School::orderBy('name')->get();
|
||||||
return view('admin.students.create',['schools' => $schools, 'minGrade' => $minGrade, 'maxGrade' => $maxGrade]);
|
|
||||||
|
return view('admin.students.create', ['schools' => $schools, 'minGrade' => $minGrade, 'maxGrade' => $maxGrade]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) abort(403);
|
if (! Auth::user()->is_admin) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
request()->validate([
|
request()->validate([
|
||||||
'first_name' => ['required'],
|
'first_name' => ['required'],
|
||||||
'last_name' => ['required'],
|
'last_name' => ['required'],
|
||||||
'grade' => ['required', 'integer'],
|
'grade' => ['required', 'integer'],
|
||||||
'school_id' => ['required', 'exists:schools,id']
|
'school_id' => ['required', 'exists:schools,id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$student = Student::create([
|
$student = Student::create([
|
||||||
'first_name' => request('first_name'),
|
'first_name' => request('first_name'),
|
||||||
'last_name' => request('last_name'),
|
'last_name' => request('last_name'),
|
||||||
'grade' => request('grade'),
|
'grade' => request('grade'),
|
||||||
'school_id' => request('school_id')
|
'school_id' => request('school_id'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect('/admin/students');
|
return redirect('/admin/students');
|
||||||
|
|
@ -52,32 +60,42 @@ class StudentController extends Controller
|
||||||
|
|
||||||
public function edit(Student $student)
|
public function edit(Student $student)
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) abort(403);
|
if (! Auth::user()->is_admin) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
$minGrade = Audition::min('minimum_grade');
|
$minGrade = Audition::min('minimum_grade');
|
||||||
$maxGrade = Audition::max('maximum_grade');
|
$maxGrade = Audition::max('maximum_grade');
|
||||||
$schools = School::orderBy('name')->get();
|
$schools = School::orderBy('name')->get();
|
||||||
|
|
||||||
return view('admin.students.edit', ['student' => $student, 'schools' => $schools, 'minGrade' => $minGrade, 'maxGrade' => $maxGrade]);
|
return view('admin.students.edit', ['student' => $student, 'schools' => $schools, 'minGrade' => $minGrade, 'maxGrade' => $maxGrade]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, Student $student)
|
public function update(Request $request, Student $student)
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) abort(403);
|
if (! Auth::user()->is_admin) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
request()->validate([
|
request()->validate([
|
||||||
'first_name' => ['required'],
|
'first_name' => ['required'],
|
||||||
'last_name' => ['required'],
|
'last_name' => ['required'],
|
||||||
'grade' => ['required', 'integer'],
|
'grade' => ['required', 'integer'],
|
||||||
'school_id' => ['required', 'exists:schools,id']
|
'school_id' => ['required', 'exists:schools,id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
foreach ($student->entries as $entry) {
|
||||||
|
if ($entry->audition->minimum_grade > request('grade') || $entry->audition->maximum_grade < request('grade')) {
|
||||||
|
return redirect('/admin/students/'.$student->id.'/edit')->with('error', 'This student is entered in an audition that is not available to their new grade.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$student->update([
|
$student->update([
|
||||||
'first_name' => request('first_name'),
|
'first_name' => request('first_name'),
|
||||||
'last_name' => request('last_name'),
|
'last_name' => request('last_name'),
|
||||||
'grade' => request('grade'),
|
'grade' => request('grade'),
|
||||||
'school_id' => request('school_id')
|
'school_id' => request('school_id'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect('/admin/students');
|
return redirect('/admin/students');
|
||||||
|
|
||||||
// TODO if a students grade is changed, we need to be sure they are still eligible for the auditions in which they are entered.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ class TabulationController extends Controller
|
||||||
return $entry->scoring_complete;
|
return $entry->scoring_complete;
|
||||||
});
|
});
|
||||||
$ensembleLimits = $this->seatingService->getLimitForAudition($audition->id);
|
$ensembleLimits = $this->seatingService->getLimitForAudition($audition->id);
|
||||||
// TODO die gracefully if no ensemble limits are set for this audition
|
|
||||||
$auditionComplete = $scoringComplete && $doublerComplete;
|
$auditionComplete = $scoringComplete && $doublerComplete;
|
||||||
|
|
||||||
$seatableEntries = $this->seatingService->getSeatableEntries($audition->id);
|
$seatableEntries = $this->seatingService->getSeatableEntries($audition->id);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ class SeatingService
|
||||||
|
|
||||||
public function getLimitForAudition($auditionId)
|
public function getLimitForAudition($auditionId)
|
||||||
{
|
{
|
||||||
|
if (! $this->getAcceptanceLimits()->has($auditionId)) {
|
||||||
|
return new \Illuminate\Database\Eloquent\Collection();
|
||||||
|
}
|
||||||
return $this->getAcceptanceLimits()[$auditionId];
|
return $this->getAcceptanceLimits()[$auditionId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue