feat: improved assignment access checks with dedicated messages

This commit is contained in:
Björn Fromme
2025-12-03 09:22:59 +01:00
parent e54e3e85b9
commit 2e34aea17e
2 changed files with 41 additions and 59 deletions
@@ -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);