-
Notifications
You must be signed in to change notification settings - Fork 15
when only one role available, autoselect it and continue to dashboard rightaway. #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| {% extends "emails/_mail-layout.twig" %} | ||
|
|
||
| {% block content %} | ||
| <div class="text-center"> | ||
| <p>{% trans %}email.payment-successful-pay-more.received{% endtrans %} {{ event.readableName }}{% trans %}email.payment-successful-pay-more.thanks{% endtrans %}</p> | ||
| <p>{% trans %}email.payment-successful-pay-more.please{% endtrans %}</p> | ||
| </div> | ||
| {% endblock %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| use kissj\Application\CookieHandler; | ||
| use kissj\Event\Event; | ||
| use kissj\Participant\ParticipantRepository; | ||
| use kissj\Participant\ParticipantRole; | ||
| use kissj\Participant\ParticipantService; | ||
| use kissj\Skautis\SkautisService; | ||
| use Psr\Http\Message\ResponseInterface as Response; | ||
|
|
@@ -109,29 +110,47 @@ public function logout(Request $request, Response $response): Response | |
| return $this->redirect($request, $response, 'landing'); | ||
| } | ||
|
|
||
| public function chooseRole(User $user, Response $response): Response | ||
| public function chooseRole(User $user, Request $request, Response $response): Response | ||
| { | ||
| $roles = $user->event->getAvailableRoles(); | ||
| if (count($roles) === 1) { | ||
| $role = $roles[0]; | ||
| if ( | ||
| $user->loginType === UserLoginType::Skautis && | ||
| !$this->skautisService->isUserLoggedIn() | ||
| ) { | ||
| $this->flashMessages->error('flash.error.skautisUserNotLoggedIn'); | ||
| return $this->redirect($request, $response, 'landing'); | ||
| } | ||
|
|
||
| $this->userService->createParticipantSetRole( | ||
| $user, | ||
| $role, | ||
| ); | ||
|
|
||
| return $this->redirect($request, $response, 'getDashboard'); | ||
|
|
||
| } | ||
| // TODO add preference into get parameter | ||
| return $this->view->render($response, 'kissj/choose-role.twig', ['event' => $user->event,]); | ||
| } | ||
|
|
||
| public function setRole(User $user, Request $request, Response $response): Response | ||
| { | ||
| $participant = $this->userService->createParticipantSetRole( | ||
| if ( | ||
| $user->loginType === UserLoginType::Skautis && | ||
| !$this->skautisService->isUserLoggedIn() | ||
| ) { | ||
| $this->flashMessages->error('flash.error.skautisUserNotLoggedIn'); | ||
| return $this->redirect($request, $response, 'landing'); | ||
|
Comment on lines
+141
to
+145
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potřeba zachovat přepoužitelnost i pro eventy, kde se přihlašuješ mailem. Smazal bych a bude fungovat OK myslím |
||
| } | ||
|
|
||
| $participantRole = ParticipantRole::from($this->getParameterFromBody($request, 'role')); | ||
| $this->userService->createParticipantSetRole( | ||
| $user, | ||
| $this->getParameterFromBody($request, 'role'), | ||
| $participantRole, | ||
| ); | ||
|
|
||
| if ($participant->getUserButNotNull()->loginType === UserLoginType::Skautis) { | ||
| if (!$this->skautisService->isUserLoggedIn()) { | ||
| $this->flashMessages->error('flash.error.skautisUserNotLoggedIn'); | ||
|
|
||
| return $this->redirect($request, $response, 'landing'); | ||
| } | ||
|
|
||
| $this->skautisService->prefillDataFromSkautis($participant); | ||
| } | ||
|
|
||
| return $this->redirect($request, $response, 'getDashboard'); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| use kissj\Participant\Participant; | ||
| use kissj\Participant\ParticipantRepository; | ||
| use kissj\Participant\ParticipantRole; | ||
| use kissj\Skautis\SkautisService; | ||
| use Psr\Http\Message\ServerRequestInterface as Request; | ||
| use Slim\Routing\RouteContext; | ||
|
|
||
|
|
@@ -18,6 +19,7 @@ | |
| public function __construct( | ||
| private LoginTokenRepository $loginTokenRepository, | ||
| private ParticipantRepository $participantRepository, | ||
| protected SkautisService $skautisService, | ||
| private UserRepository $userRepository, | ||
| private Mailer $mailer, | ||
| ) { | ||
|
|
@@ -116,9 +118,8 @@ public function invalidateAllLoginTokens(User $user): void | |
| } | ||
| } | ||
|
|
||
| public function createParticipantSetRole(User $user, string $role): Participant | ||
| public function createParticipantSetRole(User $user, ParticipantRole $participantRole): Participant | ||
| { | ||
| $participantRole = ParticipantRole::from($role); | ||
|
|
||
| $participant = new Participant(); | ||
| $participant->user = $user; | ||
|
|
@@ -128,6 +129,10 @@ public function createParticipantSetRole(User $user, string $role): Participant | |
| $user->role = UserRole::Participant; // TODO move into entity creation (simple) | ||
| $user->status = UserStatus::Open; | ||
| $this->userRepository->persist($user); | ||
|
|
||
| if ($user->loginType === UserLoginType::Skautis) { | ||
| $this->skautisService->prefillDataFromSkautis($participant); | ||
| } | ||
|
Comment on lines
+132
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Toto mega dává smysl. Nejradši bych sem přesunul logiku i z |
||
|
|
||
| return $participant; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je tu bummer s tím, že se to nemusí použít jen na Korbo a je potřeba, aby to fungovalo i s eventy, kde je na přihlášení použitý email místo skautisu. Ale vlastně by to mělo jít celé smazat a mělo by to fungovat i s tím myslím