Auditionadmin 64 #71

Merged
okorpheus merged 9 commits from auditionadmin-64 into master 2024-08-11 04:16:54 +00:00
3 changed files with 49 additions and 0 deletions
Showing only changes of commit 4d3369fb11 - Show all commits

View File

@ -191,4 +191,24 @@ class SchoolController extends Controller
return redirect()->back()->with('success', 'Director added'); return redirect()->back()->with('success', 'Director added');
} }
public function setHeadDirector(School $school, User $user, SetHeadDirector $headSetter)
{
if (auth()->user()->school_id !== $school->id) {
return redirect()->back()->with('error', 'No setting the head director for another school');
}
if (! auth()->user()->hasFlag('head_director')) {
return redirect()->back()->with('error', 'Only the head director can name a new head director');
}
if ($school->id !== $user->school_id) {
return redirect()->back()->with('error', 'The proposed head director must be at your school');
}
try {
$headSetter->setHeadDirector($user);
} catch (AuditionAdminException $e) {
return redirect()->back()->with('error', $e->getMessage());
}
return redirect()->back()->with('success', 'New head director set');
}
} }

View File

@ -67,6 +67,34 @@
<x-modal-body showVar="changeHeadDirectorForm"> <x-modal-body showVar="changeHeadDirectorForm">
<x-slot:title>Change Head Director</x-slot:title> <x-slot:title>Change Head Director</x-slot:title>
{{-- Warming Message --}}
<div class="rounded-md bg-red-50 p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">WARNING!!!</h3>
<div class="mt-2 text-sm text-red-700">
<p>After making another director head, you will no longer have access to head director functions</p>
<p>This action cannot be undone</p>
</div>
</div>
</div>
</div>
<p class="mt-3 border-b border-t py-3">Which director should be the head director at {{$school->name}}? (click to set)</p>
<x-card.list.body>
@foreach($school->directors as $director)
@continue($director->id === auth()->user()->id)
<x-card.list.row>
<a href="{{route('schools.set_head_director',['school'=>$school,'user'=>$director])}}">
{{ $director->full_name() }} < {{$director->email }} >
</a>
</x-card.list.row>
@endforeach
</x-card.list.body>
</x-modal-body> </x-modal-body>
@endif @endif
</div> </div>

View File

@ -53,6 +53,7 @@ Route::middleware(['auth', 'verified'])->controller(SchoolController::class)->gr
Route::get('/schools/{school}', 'show')->name('schools.show'); Route::get('/schools/{school}', 'show')->name('schools.show');
Route::patch('/schools/{school}', 'update')->name('schools.update'); Route::patch('/schools/{school}', 'update')->name('schools.update');
Route::post('schools/{school}/add_director', 'addDirector')->name('schools.add_director'); Route::post('schools/{school}/add_director', 'addDirector')->name('schools.add_director');
Route::get('/schools/{school}/set_head_director/{user}', 'setHeadDirector')->name('schools.set_head_director');
}); });
// Doubler Related Routes // Doubler Related Routes