From cd4c61e82c3293b0e1b9dc78dc3fef12a13a6dc1 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Sat, 28 Nov 2020 13:08:00 +0100 Subject: [PATCH 01/19] Add joinurl and mode to schema and entity --- src/Entity/Party.php | 27 +++++++++++++++++++++++++++ src/ORM/Mapping/Party.orm.xml | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/src/Entity/Party.php b/src/Entity/Party.php index daaf9711..4192f6d4 100644 --- a/src/Entity/Party.php +++ b/src/Entity/Party.php @@ -68,6 +68,12 @@ class Party */ private $confirmed; + /** @var string */ + private $joinurl = ''; + + /** @var int */ + private $joinmode = 0; + public function __construct($createDefaults = true) { $this->participants = new ArrayCollection(); @@ -81,6 +87,7 @@ public function __construct($createDefaults = true) $this->creationdate = new \DateTime(); $this->message = ''; $this->location = ''; + $this->joinurl = base_convert(sha1(uniqid((string) mt_rand(), true)), 16, 36); } /** @@ -292,6 +299,26 @@ public function setConfirmed(bool $confirmed) $this->confirmed = (string) $confirmed; } + public function getJoinurl(): string + { + return $this->joinurl; + } + + public function setJoinurl(string $joinurl): void + { + $this->joinurl = $joinurl; + } + + public function getJoinmode(): int + { + return $this->joinmode; + } + + public function setJoinmode(int $joinmode): void + { + $this->joinmode = $joinmode; + } + /** * @return array */ diff --git a/src/ORM/Mapping/Party.orm.xml b/src/ORM/Mapping/Party.orm.xml index f50bf4de..1c0e3038 100644 --- a/src/ORM/Mapping/Party.orm.xml +++ b/src/ORM/Mapping/Party.orm.xml @@ -10,6 +10,7 @@ + @@ -34,6 +35,9 @@ + + + From 80ef15245a4b4023f05ba92689a0bdf1de69080d Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 19:22:30 +0100 Subject: [PATCH 02/19] No need for explicit index as unique=true creates index --- src/ORM/Mapping/Party.orm.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ORM/Mapping/Party.orm.xml b/src/ORM/Mapping/Party.orm.xml index 1c0e3038..c5068cf4 100644 --- a/src/ORM/Mapping/Party.orm.xml +++ b/src/ORM/Mapping/Party.orm.xml @@ -10,7 +10,6 @@ - @@ -36,7 +35,7 @@ - + From 9e1e85e0c85d2de35eeea5890367346c01ff670c Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 21:30:17 +0100 Subject: [PATCH 03/19] Joinurl nullable --- src/Entity/Party.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Entity/Party.php b/src/Entity/Party.php index 4192f6d4..0a4f5cff 100644 --- a/src/Entity/Party.php +++ b/src/Entity/Party.php @@ -68,8 +68,8 @@ class Party */ private $confirmed; - /** @var string */ - private $joinurl = ''; + /** @var ?string */ + private $joinurl; /** @var int */ private $joinmode = 0; @@ -299,12 +299,12 @@ public function setConfirmed(bool $confirmed) $this->confirmed = (string) $confirmed; } - public function getJoinurl(): string + public function getJoinurl(): ?string { return $this->joinurl; } - public function setJoinurl(string $joinurl): void + public function setJoinurl(?string $joinurl): void { $this->joinurl = $joinurl; } From 1cd9fede76ce2b296b0db67c03f33d716b3db73f Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 21:32:15 +0100 Subject: [PATCH 04/19] Add SetJoinMode form and controller logic --- src/Controller/Party/ManagementController.php | 32 +++++++++++++++++ .../Form/Type/SetJoinModeType.php | 35 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php diff --git a/src/Controller/Party/ManagementController.php b/src/Controller/Party/ManagementController.php index b9cad72e..f76b5f5d 100644 --- a/src/Controller/Party/ManagementController.php +++ b/src/Controller/Party/ManagementController.php @@ -6,6 +6,7 @@ use App\Entity\Party; use App\Form\Handler\AddParticipantFormHandler; +use App\Form\Type\SetJoinModeType; use App\Mailer\MailerService; use App\Service\PartyService; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; @@ -50,6 +51,9 @@ public function validAction(Party $party, Form $excludeForm = null) $updatePartyDetailsForm = $this->createForm(UpdatePartyDetailsType::class, $party, [ 'action' => $this->generateUrl('party_manage_update', ['listurl' => $party->getListurl()]), ]); + $setJoinModeForm = $this->createForm(SetJoinModeType::class, $party, [ + 'action' => $this->generateUrl('party_manage_joinmode', ['listurl' => $party->getListurl()]), + ]); if ($excludeForm === null) { $excludeForm = $this->createForm(PartyExcludeParticipantType::class, $party, [ @@ -64,6 +68,7 @@ public function validAction(Party $party, Form $excludeForm = null) 'delete_party_csrf_token' => $this->get('security.csrf.token_manager')->getToken('delete_party'), 'delete_participant_csrf_token' => $this->get('security.csrf.token_manager')->getToken('delete_participant'), 'excludeForm' => $excludeForm->createView(), + 'setJoinModeForm' => $setJoinModeForm->createView(), ]; } @@ -144,4 +149,31 @@ public function excludeAction(Request $request, Party $party) return $this->redirectToRoute('party_manage', ['listurl' => $party->getListurl()]); } + + /** + * @Route("/manage/joinmode/{listurl}", name="party_manage_joinmode", methods={"POST"}) + */ + public function joinModeAction(Request $request, Party $party) + { + $party->setConfirmed(true); + $setJoinModeForm = $this->createForm(SetJoinModeType::class, $party, []); + $setJoinModeForm->handleRequest($request); + + if ($setJoinModeForm->isSubmitted() && $setJoinModeForm->isValid()) { + + if (($party->getJoinmode() == 1 && $party->getJoinurl() === null) || $request->request->get('reset', 0) == '1') { + // generate join URL + $party->setJoinurl(base_convert(sha1(uniqid((string) mt_rand(), true)), 16, 36)); + } + + $this->getDoctrine()->getManager()->persist($party); + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('success', $this->get('translator')->trans('flashes.management.join_mode.success')); + } else { + $this->addFlash('danger', $this->get('translator')->trans('flashes.management.join_mode.danger')); + } + + return $this->redirectToRoute('party_manage', ['listurl' => $party->getListurl()]); + } } diff --git a/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php b/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php new file mode 100644 index 00000000..6e170b74 --- /dev/null +++ b/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php @@ -0,0 +1,35 @@ +add( + 'join_mode', + ChoiceType::class, + [ + 'attr' => ['data-hj-masked' => ''], + 'choices' => [ 'party_manage_valid.join_mode.mode.no' => '0', 'party_manage_valid.join_mode.mode.yes' => '1'], + 'expanded' => true, + 'multiple' => false, + ] + ) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Party::class, + ]); + } +} From 91d26636b899ad270b592bd4f4998574d6c1daef Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 21:33:02 +0100 Subject: [PATCH 05/19] Add join by link --- assets/js/party.manage.js | 5 ++++ templates/Party/manage/valid.html.twig | 33 ++++++++++++++++++++++++++ translations/messages.en.yml | 20 ++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/assets/js/party.manage.js b/assets/js/party.manage.js index 9d133657..d75aba81 100644 --- a/assets/js/party.manage.js +++ b/assets/js/party.manage.js @@ -44,6 +44,11 @@ $(document).ready(function () { $('.link_remove_participant').attr('disabled', false); }); + $('#btn_join').click(function (e) { + $('#join-mode').show(); + $('#btn_join').attr('disabled', true); + }); + if (Modernizr.inputtypes.date == true) { $("#intracto_secretsantabundle_updatepartydetailstype_eventdate").click(function (e) { $(this).datepicker({dateFormat: 'dd-mm-yy'}); diff --git a/templates/Party/manage/valid.html.twig b/templates/Party/manage/valid.html.twig index 2cb032c6..6c00fe22 100644 --- a/templates/Party/manage/valid.html.twig +++ b/templates/Party/manage/valid.html.twig @@ -109,6 +109,9 @@ {% if (form_errors(addParticipantForm.name)) or (form_errors(addParticipantForm.email)) %}disabled{% endif %}> {{ 'party_manage_valid.btn.add_participant'|trans|raw }} +
+
+ {% if party.created %}
diff --git a/translations/messages.en.yml b/translations/messages.en.yml index 7a6904a3..262a12e4 100644 --- a/translations/messages.en.yml +++ b/translations/messages.en.yml @@ -416,6 +416,21 @@ party_manage_valid: Your participants will be notified of these changes immediately.

+ join_mode: + title: Join by link settings + body: > +

+ Instead of manually adding people, you can allow people to join your party by sharing a link. +
When you start the party, people aren't able to join anymore (but you can still add them manually). +

+ mode: + no: No, do not allow people to join by link + yes: Yes, allow anyone with the link to join my party + reset_body: > + By checking this checkbox, a new link will be generated. People will not be able to join with the old link anymore. + Use this when the current link has been shared with people that are not supposed to be able to join. + reset_unset: Enable join by link to generate a link. + btn: add_participant: Add participant to party add_participant_confirm: Add this participant @@ -428,6 +443,8 @@ party_manage_valid: remove_participant_confirm: Remove this participant updated_party: Update your party details start_party: Start your party + join_mode: Join by link + join_mode_confirm: Set join mode label: name: Name @@ -435,6 +452,9 @@ party_manage_valid: confirmed: Email status wishlist_filled: Wish List Entered actions: Actions + join_mode: Allow join by link + join_url: Share this URL with your friends + reset: Reset join URL excludes: title: Exclude certain combinations From c1863fe6d4a89c8217f9e51ae689efc029ef4313 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 21:54:23 +0100 Subject: [PATCH 06/19] Remove unwanted text --- templates/Party/manage/valid.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/Party/manage/valid.html.twig b/templates/Party/manage/valid.html.twig index 6c00fe22..37fd953c 100644 --- a/templates/Party/manage/valid.html.twig +++ b/templates/Party/manage/valid.html.twig @@ -125,7 +125,7 @@ {{ form_row(addParticipantForm._token) }}
{{ 'party_manage_valid.label.name'|trans }} {{ form_widget(addParticipantForm.name ,{'attr':{'class':'form-control'}}) }} - {% if form_errors(addParticipantForm.name) %}addParticipantForm + {% if form_errors(addParticipantForm.name) %} {% for error in addParticipantForm.name.vars.errors %} {{ error.message }}
{% endfor %} From b8dbc8f3c5cacb563be1da7eaf3a1244a987c997 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 23:06:53 +0100 Subject: [PATCH 07/19] fix colors --- templates/Party/manage/valid.html.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/Party/manage/valid.html.twig b/templates/Party/manage/valid.html.twig index 37fd953c..3a6ca72f 100644 --- a/templates/Party/manage/valid.html.twig +++ b/templates/Party/manage/valid.html.twig @@ -164,7 +164,7 @@
- From fd71857acb567e0e591c9a95ddc4ba477f768eef Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 23:08:00 +0100 Subject: [PATCH 08/19] Participant can join party --- .../Controller/Participant/JoinController.php | 68 +++++++++++++++++++ .../Handler/JoinParticipantFormHandler.php | 52 ++++++++++++++ .../views/Participant/show/join.html.twig | 66 ++++++++++++++++++ translations/messages.en.yml | 28 ++++++++ 4 files changed, 214 insertions(+) create mode 100644 src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php create mode 100644 src/Intracto/SecretSantaBundle/Form/Handler/JoinParticipantFormHandler.php create mode 100644 src/Intracto/SecretSantaBundle/Resources/views/Participant/show/join.html.twig diff --git a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php new file mode 100644 index 00000000..4f84853e --- /dev/null +++ b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php @@ -0,0 +1,68 @@ +findOneBy(['joinurl' => $joinurl, 'joinmode' => 1, 'created' => 0]); + + if (null !== $party) { + $addParticipantForm = $this->createForm(AddParticipantType::class, new Participant(), [ + 'action' => $this->generateUrl('join_party', ['joinurl' => $party->getJoinurl()]), + ]); + $addParticipantForm->handleRequest($request); + + if ($addParticipantForm->isSubmitted() && $addParticipantForm->isValid()) { + /** @var Participant $newParticipant */ + $newParticipant = $addParticipantForm->getData(); + $newParticipant->setParty($party); + $this->getDoctrine()->getManager()->persist($newParticipant); + $this->getDoctrine()->getManager()->flush(); + return $this->redirectToRoute('join_party_joined', [ 'joinurl' => $party->getJoinurl() ]); + } + } + + return [ + 'party' => $party, + 'form' => isset($addParticipantForm) ? $addParticipantForm->createView() : null, + ]; + + } + + /** + * @Route("/joined/{joinurl}", name="join_party_joined") + * @Template("IntractoSecretSantaBundle:Participant:show/join.html.twig") + */ + public function joinedAction(string $joinurl, PartyRepository $partyRepository) + { + /** @var Party $party */ + $party = $partyRepository->findOneBy(['joinurl' => $joinurl, 'joinmode' => 1, 'created' => 0]); + + return [ + 'party' => $party, + 'form' => null, + ]; + } + +} diff --git a/src/Intracto/SecretSantaBundle/Form/Handler/JoinParticipantFormHandler.php b/src/Intracto/SecretSantaBundle/Form/Handler/JoinParticipantFormHandler.php new file mode 100644 index 00000000..1ae3a079 --- /dev/null +++ b/src/Intracto/SecretSantaBundle/Form/Handler/JoinParticipantFormHandler.php @@ -0,0 +1,52 @@ +translator = $translator; + $this->session = $session; + $this->em = $em; + } + + public function handle(FormInterface $form, Request $request, Party $party): void + { + /** @var Participant $newParticipant */ + $newParticipant = $form->getData(); + + if (!$request->isMethod('POST')) { + return; + } + + if (!$form->handleRequest($request)->isValid()) { + $this->session->getFlashBag()->add('danger', $this->translator->trans('flashes.management.add_participant.danger')); + + return; + } + + $newParticipant->setParty($party); + + $this->em->persist($newParticipant); + $this->em->flush(); + + $this->session->getFlashBag()->add('success', $this->translator->trans('flashes.management.add_participant.success')); + } +} diff --git a/src/Intracto/SecretSantaBundle/Resources/views/Participant/show/join.html.twig b/src/Intracto/SecretSantaBundle/Resources/views/Participant/show/join.html.twig new file mode 100644 index 00000000..48035fd3 --- /dev/null +++ b/src/Intracto/SecretSantaBundle/Resources/views/Participant/show/join.html.twig @@ -0,0 +1,66 @@ +{% extends "IntractoSecretSantaBundle:Participant/show:base.html.twig" %} + +{% block main %} +
+
+
+

{{ 'party_join.title'|trans }}

+ + {% if party is not null %} + + {{ 'party_join.description'|trans|raw }} + + {% if form is null %} +
+ {{ 'party_join.joined'|trans|raw }} +
+ {% endif %} + +
+

{{ 'participant_show_base.headers.title'|trans|raw }}

+
+
    +
  • {{ 'participant_show_base.headers.date'|trans }}: {{ party.eventdate|localizeddate('medium', 'none') }}
  • +
  • {{ 'participant_show_base.headers.location'|trans }}: {{ party.location }}
  • +
  • {{ 'participant_show_base.headers.amount'|trans }}: {{ party.amount }}
  • +
  • {{ 'participant_show_base.headers.person_created_list'|trans }}: {{ party.participants|first.name }} ({{ party.participants|first.email }}) +
+
+
+ + {% if form is not null %} + {{ form_start(form) }} + {{ form_row(form._token) }} +
+ {{ 'party_manage_valid.label.name'|trans }} {{ form_widget(form.name ,{'attr':{'class':'form-control'}}) }} + {% if form_errors(form.name) %} + {% for error in form.name.vars.errors %} + {{ error.message }}
+ {% endfor %} + {% endif %} +
+
+ {{ 'party_manage_valid.label.email'|trans }} {{ form_widget(form.email ,{'attr':{'class':'form-control'}}) }} + {% if form_errors(form.email) %} + {% for error in form.email.vars.errors %} + {{ error.message }}
+ {% endfor %} + {% endif %} +
+ + + {{ form_end(form) }} + {% endif %} + {% else %} +
+ {{ 'party_join.invalid'|trans|raw }} +
+ {% endif %} + +
+
+ +
+ +{% endblock %} diff --git a/translations/messages.en.yml b/translations/messages.en.yml index 262a12e4..4955874e 100644 --- a/translations/messages.en.yml +++ b/translations/messages.en.yml @@ -467,6 +467,34 @@ party_manage_valid: name: Name exclude: Exclude +party_join: + title: Join the party! + description: > +

+ With the link you were given, you can add yourself to this Secret Santa party! + Please review the party details below, and fill out the form if you want to participate. + If you have questions regarding the party, please contact the person who created this party. +

+ joined: > +

+ We have added you to the party! +
Note that you will not receive your match until the party is started. + If you have any questions regarding the party or want to change your info, you must contact the person who created this party! +

+ invalid: > +

+ The link you have used is not valid. There could be several reasons for this +

    +
  • The party does not exists, or has been deleted.
  • +
  • The creator of the party has disabled or reset the link.
  • +
  • The party has already been started.
  • +
+ Please contact the person that sent you the link. He or she might still be able to add you to the party manually! +

+ + btn: + join_confirm: Join party + # Emails/baseEmail.html.twig emails-base_email: sender: Santa Claus From 0d3ae22877a09b9cb2de606f64ccacb2dd623b29 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 23:14:43 +0100 Subject: [PATCH 09/19] Full URL to join link --- templates/Party/manage/valid.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/Party/manage/valid.html.twig b/templates/Party/manage/valid.html.twig index 3a6ca72f..1527d8c7 100644 --- a/templates/Party/manage/valid.html.twig +++ b/templates/Party/manage/valid.html.twig @@ -182,7 +182,7 @@ {% endif %}

- {{ 'party_manage_valid.label.join_url'|trans }} + {{ 'party_manage_valid.label.join_url'|trans }}
{{ 'party_manage_valid.label.reset'|trans }} From 235060a1afbbd16bd6d37d0badc08cffdfaa52e5 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 23:17:25 +0100 Subject: [PATCH 10/19] Add missing flash messages --- translations/messages.en.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/translations/messages.en.yml b/translations/messages.en.yml index 4955874e..86623601 100644 --- a/translations/messages.en.yml +++ b/translations/messages.en.yml @@ -734,6 +734,9 @@ flashes: add_participant: success:

Added!

Participant successfully added to your party. danger:

Oops

An error occurred while adding the participant. Please try again. + join_mode: + success:

Updated!

The join by link settings have been successfully updated. + danger:

Oops

An error has occurred while updating the join by link settings. Please try again. updated_party: success:

Updated!

Your party details have been successfully updated. danger:

Oops

An error has occurred while updating your party. Please try again. From 353d79e356ad3fff345763f3fbbe8345db4dbf73 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 23:33:22 +0100 Subject: [PATCH 11/19] StyleCI fixes --- src/Controller/Party/ManagementController.php | 1 - .../Controller/Participant/JoinController.php | 4 +--- src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Controller/Party/ManagementController.php b/src/Controller/Party/ManagementController.php index f76b5f5d..1ab124b8 100644 --- a/src/Controller/Party/ManagementController.php +++ b/src/Controller/Party/ManagementController.php @@ -160,7 +160,6 @@ public function joinModeAction(Request $request, Party $party) $setJoinModeForm->handleRequest($request); if ($setJoinModeForm->isSubmitted() && $setJoinModeForm->isValid()) { - if (($party->getJoinmode() == 1 && $party->getJoinurl() === null) || $request->request->get('reset', 0) == '1') { // generate join URL $party->setJoinurl(base_convert(sha1(uniqid((string) mt_rand(), true)), 16, 36)); diff --git a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php index 4f84853e..639a243e 100644 --- a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php +++ b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php @@ -8,12 +8,10 @@ use Intracto\SecretSantaBundle\Form\Type\AddParticipantType; use Intracto\SecretSantaBundle\Repository\PartyRepository; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Intracto\SecretSantaBundle\Entity\Party; -use Symfony\Component\Translation\TranslatorInterface; class JoinController extends AbstractController { @@ -39,7 +37,7 @@ public function joinAction(Request $request, string $joinurl, PartyRepository $p $newParticipant->setParty($party); $this->getDoctrine()->getManager()->persist($newParticipant); $this->getDoctrine()->getManager()->flush(); - return $this->redirectToRoute('join_party_joined', [ 'joinurl' => $party->getJoinurl() ]); + return $this->redirectToRoute('join_party_joined', ['joinurl' => $party->getJoinurl()]); } } diff --git a/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php b/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php index 6e170b74..0b6a8dad 100644 --- a/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php +++ b/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php @@ -18,7 +18,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ChoiceType::class, [ 'attr' => ['data-hj-masked' => ''], - 'choices' => [ 'party_manage_valid.join_mode.mode.no' => '0', 'party_manage_valid.join_mode.mode.yes' => '1'], + 'choices' => ['party_manage_valid.join_mode.mode.no' => '0', 'party_manage_valid.join_mode.mode.yes' => '1'], 'expanded' => true, 'multiple' => false, ] From 09e0bc7da4e531287e2111e592e9b239cf45292f Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 23:35:28 +0100 Subject: [PATCH 12/19] StyleCI fixes --- .../Controller/Participant/JoinController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php index 639a243e..33d1b07a 100644 --- a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php +++ b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php @@ -21,7 +21,6 @@ class JoinController extends AbstractController */ public function joinAction(Request $request, string $joinurl, PartyRepository $partyRepository) { - /** @var Party $party */ $party = $partyRepository->findOneBy(['joinurl' => $joinurl, 'joinmode' => 1, 'created' => 0]); @@ -37,6 +36,7 @@ public function joinAction(Request $request, string $joinurl, PartyRepository $p $newParticipant->setParty($party); $this->getDoctrine()->getManager()->persist($newParticipant); $this->getDoctrine()->getManager()->flush(); + return $this->redirectToRoute('join_party_joined', ['joinurl' => $party->getJoinurl()]); } } @@ -45,7 +45,6 @@ public function joinAction(Request $request, string $joinurl, PartyRepository $p 'party' => $party, 'form' => isset($addParticipantForm) ? $addParticipantForm->createView() : null, ]; - } /** From 8faf282aeebfa7350bc0dc0949568982bdd2df3f Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Mon, 30 Nov 2020 23:36:27 +0100 Subject: [PATCH 13/19] StyleCI fixes --- .../SecretSantaBundle/Controller/Participant/JoinController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php index 33d1b07a..c9676b59 100644 --- a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php +++ b/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php @@ -61,5 +61,4 @@ public function joinedAction(string $joinurl, PartyRepository $partyRepository) 'form' => null, ]; } - } From 8cf7e1a77dadccec2f2abae976edbc6b829c227d Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Tue, 1 Dec 2020 21:30:30 +0100 Subject: [PATCH 14/19] Use translator instead of container --- src/Controller/Party/ManagementController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/Party/ManagementController.php b/src/Controller/Party/ManagementController.php index 1ab124b8..574082be 100644 --- a/src/Controller/Party/ManagementController.php +++ b/src/Controller/Party/ManagementController.php @@ -168,9 +168,9 @@ public function joinModeAction(Request $request, Party $party) $this->getDoctrine()->getManager()->persist($party); $this->getDoctrine()->getManager()->flush(); - $this->addFlash('success', $this->get('translator')->trans('flashes.management.join_mode.success')); + $this->addFlash('success', $this->translator->trans('flashes.management.join_mode.success')); } else { - $this->addFlash('danger', $this->get('translator')->trans('flashes.management.join_mode.danger')); + $this->addFlash('danger', $this->translator->trans('flashes.management.join_mode.danger')); } return $this->redirectToRoute('party_manage', ['listurl' => $party->getListurl()]); From 94978a628c4102c0408236a0dcbcab024f389ea5 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Tue, 1 Dec 2020 21:33:51 +0100 Subject: [PATCH 15/19] Fix namespaces and SF4 specifics --- .../Controller/Participant/JoinController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename src/{Intracto/SecretSantaBundle => }/Controller/Participant/JoinController.php (86%) diff --git a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php b/src/Controller/Participant/JoinController.php similarity index 86% rename from src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php rename to src/Controller/Participant/JoinController.php index c9676b59..38e48d3f 100644 --- a/src/Intracto/SecretSantaBundle/Controller/Participant/JoinController.php +++ b/src/Controller/Participant/JoinController.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Intracto\SecretSantaBundle\Controller\Participant; +namespace App\Controller\Participant; -use Intracto\SecretSantaBundle\Entity\Participant; -use Intracto\SecretSantaBundle\Form\Type\AddParticipantType; -use Intracto\SecretSantaBundle\Repository\PartyRepository; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use App\Entity\Participant; +use App\Entity\Party; +use App\Form\Type\AddParticipantType; +use App\Repository\PartyRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; -use Intracto\SecretSantaBundle\Entity\Party; +use Symfony\Component\Routing\Annotation\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; class JoinController extends AbstractController { From c07f4a762d4081ba11b0eeada9cd36e4eaa32837 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Tue, 1 Dec 2020 21:34:37 +0100 Subject: [PATCH 16/19] Fix template path --- src/Controller/Participant/JoinController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/Participant/JoinController.php b/src/Controller/Participant/JoinController.php index 38e48d3f..f4885f95 100644 --- a/src/Controller/Participant/JoinController.php +++ b/src/Controller/Participant/JoinController.php @@ -17,7 +17,7 @@ class JoinController extends AbstractController { /** * @Route("/join/{joinurl}", name="join_party") - * @Template("IntractoSecretSantaBundle:Participant:show/join.html.twig") + * @Template("Participant/show/join.html.twig") */ public function joinAction(Request $request, string $joinurl, PartyRepository $partyRepository) { From 42e2f0c66d810662f26e8bba08f1b2d39bad90e6 Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Tue, 1 Dec 2020 21:35:47 +0100 Subject: [PATCH 17/19] Change date --- .../views => templates}/Participant/show/join.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {src/Intracto/SecretSantaBundle/Resources/views => templates}/Participant/show/join.html.twig (95%) diff --git a/src/Intracto/SecretSantaBundle/Resources/views/Participant/show/join.html.twig b/templates/Participant/show/join.html.twig similarity index 95% rename from src/Intracto/SecretSantaBundle/Resources/views/Participant/show/join.html.twig rename to templates/Participant/show/join.html.twig index 48035fd3..a43957e1 100644 --- a/src/Intracto/SecretSantaBundle/Resources/views/Participant/show/join.html.twig +++ b/templates/Participant/show/join.html.twig @@ -1,4 +1,4 @@ -{% extends "IntractoSecretSantaBundle:Participant/show:base.html.twig" %} +{% extends "Participant/show/base.html.twig" %} {% block main %}
@@ -20,7 +20,7 @@

{{ 'participant_show_base.headers.title'|trans|raw }}

    -
  • {{ 'participant_show_base.headers.date'|trans }}: {{ party.eventdate|localizeddate('medium', 'none') }}
  • +
  • {{ 'participant_show_base.headers.date'|trans }}: {{ party.eventdate|format_datetime('medium', 'none') }}
  • {{ 'participant_show_base.headers.location'|trans }}: {{ party.location }}
  • {{ 'participant_show_base.headers.amount'|trans }}: {{ party.amount }}
  • {{ 'participant_show_base.headers.person_created_list'|trans }}: {{ party.participants|first.name }} ({{ party.participants|first.email }}) From 61acdc4c525f2a903155a4f18a0499913dc6092b Mon Sep 17 00:00:00 2001 From: Tom Cannaerts Date: Tue, 1 Dec 2020 21:36:52 +0100 Subject: [PATCH 18/19] Fix namespaces and SF4 specifics --- .../Form/Handler/JoinParticipantFormHandler.php | 14 ++++++-------- .../Form/Type/SetJoinModeType.php | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) rename src/{Intracto/SecretSantaBundle => }/Form/Handler/JoinParticipantFormHandler.php (78%) rename src/{Intracto/SecretSantaBundle => }/Form/Type/SetJoinModeType.php (90%) diff --git a/src/Intracto/SecretSantaBundle/Form/Handler/JoinParticipantFormHandler.php b/src/Form/Handler/JoinParticipantFormHandler.php similarity index 78% rename from src/Intracto/SecretSantaBundle/Form/Handler/JoinParticipantFormHandler.php rename to src/Form/Handler/JoinParticipantFormHandler.php index 1ae3a079..662bdd27 100644 --- a/src/Intracto/SecretSantaBundle/Form/Handler/JoinParticipantFormHandler.php +++ b/src/Form/Handler/JoinParticipantFormHandler.php @@ -2,23 +2,21 @@ declare(strict_types=1); -namespace Intracto\SecretSantaBundle\Form\Handler; +namespace App\Form\Handler; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; -use Intracto\SecretSantaBundle\Entity\Participant; -use Intracto\SecretSantaBundle\Entity\Party; +use App\Entity\Participant; +use App\Entity\Party; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class JoinParticipantFormHandler { private TranslatorInterface $translator; - private Session $session; - private EntityManager $em; + private SessionInterface $session; + private EntityManagerInterface $em; public function __construct(TranslatorInterface $translator, SessionInterface $session, EntityManagerInterface $em) { diff --git a/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php b/src/Form/Type/SetJoinModeType.php similarity index 90% rename from src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php rename to src/Form/Type/SetJoinModeType.php index 0b6a8dad..def6136d 100644 --- a/src/Intracto/SecretSantaBundle/Form/Type/SetJoinModeType.php +++ b/src/Form/Type/SetJoinModeType.php @@ -1,8 +1,8 @@ Date: Tue, 1 Dec 2020 21:38:58 +0100 Subject: [PATCH 19/19] Fix namespaces and SF4 specifics --- src/Controller/Participant/JoinController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/Participant/JoinController.php b/src/Controller/Participant/JoinController.php index f4885f95..1171b3b4 100644 --- a/src/Controller/Participant/JoinController.php +++ b/src/Controller/Participant/JoinController.php @@ -49,7 +49,7 @@ public function joinAction(Request $request, string $joinurl, PartyRepository $p /** * @Route("/joined/{joinurl}", name="join_party_joined") - * @Template("IntractoSecretSantaBundle:Participant:show/join.html.twig") + * @Template("Participant/show/join.html.twig") */ public function joinedAction(string $joinurl, PartyRepository $partyRepository) {