feat: improved assignment access checks with dedicated messages
This commit is contained in:
@@ -31,6 +31,27 @@ class CreateController extends AbstractController
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
|
||||
// Only allow applications on empty slots
|
||||
$availableSlots = (int) $assignment->getAvailableDispositions();
|
||||
if (0 < $availableSlots) {
|
||||
$this->addFlash('error', 'Auf diesem Einsatz sind bereits alle Plätze belegt');
|
||||
|
||||
return $this->redirectToRoute('app_teamer_index');
|
||||
}
|
||||
|
||||
// Only teamers without existing applications may apply to the assignment
|
||||
$existingApplication = $this
|
||||
->entityManager
|
||||
->getRepository(Application::class)
|
||||
->findOneBy(['teamer' => $teamer, 'assignment' => $assignment]);
|
||||
|
||||
if (null !== $existingApplication) {
|
||||
$this->addFlash('error', 'Du hast dich bereits auf diesen Einsatz beworben');
|
||||
|
||||
return $this->redirectToRoute('app_teamer_index');
|
||||
}
|
||||
|
||||
$application = new Application($assignment, $teamer);
|
||||
|
||||
$form = $this->createForm(TeamerApplicationType::class, $application);
|
||||
|
||||
Reference in New Issue
Block a user