diff --git a/.env b/.env index 126ff163..bb37a150 100644 --- a/.env +++ b/.env @@ -70,6 +70,7 @@ OAUTH_KEYCLOAK_REALM=addHere ###> demo ### demo_installation=prod #demo +APP_DEMO=0 ###< demo ### ###> LaF ### diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 06020e21..4eacfeb4 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -12,4 +12,5 @@ twig: dataPrivacy: '%env(dataPrivacy)%' supportMail: '%env(SUPPORT_MAIL)%' demo: '%env(demo_installation)%' - laf_version: '%env(laF_version)%' \ No newline at end of file + laf_version: '%env(laF_version)%' + APP_DEMO: '%env(APP_DEMO)%' \ No newline at end of file diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php index 31e5d026..9769a3e5 100644 --- a/src/Controller/DashboardController.php +++ b/src/Controller/DashboardController.php @@ -14,6 +14,8 @@ namespace App\Controller; +use App\Entity\Team; +use App\Form\Type\TeamType; use App\Repository\AkademieBuchungenRepository; use App\Repository\AuditTomRepository; use App\Repository\DatenweitergabeRepository; @@ -150,6 +152,26 @@ public function noTeam(): Response ]); } + #[Route(path: '/no_team/create', name: 'no_team_create')] + public function noTeamCreate(): Response + { + if (!$_ENV['APP_DEMO']) { + return $this->redirectToRoute('dashboard'); + } + + $team = (new Team())->setActiv(true); + $form = $this->createForm(TeamType::class, $team, [ + 'action' => $this->generateUrl('team_create') + ]) + ->remove('video') + ->remove('externalLink'); + + return $this->render('dashboard/noteamCreate.html.twig', [ + 'user' => $this->getUser(), + 'form' => $form->createView(), + ]); + } + private function getTabsAssignments(): array { return [ diff --git a/src/Controller/TeamController.php b/src/Controller/TeamController.php index e805d6a1..8bd02a85 100644 --- a/src/Controller/TeamController.php +++ b/src/Controller/TeamController.php @@ -120,6 +120,7 @@ public function create( ValidatorInterface $validator, EntityManagerInterface $em, Request $request, + CurrentTeamService $teamService, ): Response { $user = $this->getUser(); @@ -140,6 +141,13 @@ public function create( $em->persist($nTeam); $em->persist($user); $em->flush(); + $this->addSuccessMessage($this->translator->trans(id: 'team.created', domain: 'team')); + + if ($_ENV['APP_DEMO']) { + $teamService->switchToTeam((string) $nTeam->getId()); + return $this->redirectToRoute('dashboard'); + } + return $this->redirectToRoute('team_edit', ['id' => $nTeam->getId()]); } } diff --git a/templates/dashboard/noteam.html.twig b/templates/dashboard/noteam.html.twig index 8717ccd9..31091038 100644 --- a/templates/dashboard/noteam.html.twig +++ b/templates/dashboard/noteam.html.twig @@ -7,10 +7,17 @@
{% trans %}noTeamHelp{% endtrans %}
-{% trans %}createTeamHelp{% endtrans %}
+ + {% trans from 'team' %}team.create{% endtrans %} + + {% else %} +{% trans %}noTeamHelp{% endtrans %}
+