From a6b15fb2fb4bc6b917c890848195d1e20fe2bdf4 Mon Sep 17 00:00:00 2001 From: Gwildor Sok Date: Tue, 21 May 2024 16:55:29 +0200 Subject: [PATCH 1/2] [SCOUT] Make signup approval work again The emails were broken because divisions can have multiple contacts now, and the list of signups did not properly filter on managed divisions. --- src/Controller/Admin/DashboardController.php | 2 +- src/Controller/Admin/MembershipApplicationCrud.php | 10 ++++++---- templates/email/html/contact_new_member.html.twig | 6 ++---- templates/email/text/contact_new_member.txt.twig | 6 ++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index acfccdb..d1469c8 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -58,7 +58,7 @@ public function configureMenuItems(): iterable MenuItem::section('Administratie'), MenuItem::linkToCrud('Leden', 'fa fa-users', Member::class), MenuItem::linkToCrud('Steunleden', 'fa fa-users', SupportMember::class)->setPermission('ROLE_ADMIN'), - MenuItem::linkToCrud('Aanmeldingen', 'fa fa-user-plus', MembershipApplication::class)->setPermission('ROLE_ADMIN'), + MenuItem::linkToCrud('Aanmeldingen', 'fa fa-user-plus', MembershipApplication::class), MenuItem::linkToCrud('Groepen', 'fa fa-building', Division::class)->setPermission('ROLE_ADMIN'), MenuItem::linkToCrud('Lidmaatschapstypes', 'fa fa-building', MembershipStatus::class)->setPermission('ROLE_ADMIN'), diff --git a/src/Controller/Admin/MembershipApplicationCrud.php b/src/Controller/Admin/MembershipApplicationCrud.php index f0003e7..90e8f9a 100644 --- a/src/Controller/Admin/MembershipApplicationCrud.php +++ b/src/Controller/Admin/MembershipApplicationCrud.php @@ -40,11 +40,11 @@ public function __construct(MailerInterface $mailer, MollieApiClient $mollieApiC public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder { $response = $this->get(EntityRepository::class)->createQueryBuilder($searchDto, $entityDto, $fields, $filters); - if (in_array('ROLE_ADMIN', $this->getUser()->getRoles(), true)) { - return $response; + + if (!in_array('ROLE_ADMIN', $this->getUser()->getRoles(), true)) { + $response->andWhere('entity.preferredDivision IN (:division)')->setParameter('division', $this->getUser()->getManagedDivisions()); } - $division = $this->getUser()->getDivision(); - $response->andWhere('entity.preferredDivision = :division')->setParameter('division', $division); + return $response; } @@ -157,11 +157,13 @@ public function acceptApplication(AdminContext $context) ->from(new Address($noreply, $organizationName)) ->html( $this->renderView($templatePrefix . 'email/html/contact_new_member.html.twig', [ + 'contact' => $contact, 'member' => $member, ]), ) ->text( $this->renderView($templatePrefix . 'email/text/contact_new_member.txt.twig', [ + 'contact' => $contact, 'member' => $member, ]), ); diff --git a/templates/email/html/contact_new_member.html.twig b/templates/email/html/contact_new_member.html.twig index 5240f37..36d5b85 100644 --- a/templates/email/html/contact_new_member.html.twig +++ b/templates/email/html/contact_new_member.html.twig @@ -1,8 +1,7 @@ {% extends 'email/html/layout.html.twig' %} -{% set url = url('division', { division: member.division.name }) %} {% block content %}

- Beste {{ member.division.contact.firstName }} {{ member.division.contact.lastName }}, + Beste {{ contact.getFullName }},

Onlangs heeft een nieuw lid zich aangemeld bij {{ organisatienaam }}: {{ member.getFullName }}. @@ -10,8 +9,7 @@ zich graag aan te sluiten bij de groep {{ member.division.name }}.

- Hun gegevens zijn toegevoegd aan het ledenoverzicht in het ledenadministratiesysteem. Klik op de onderstaande link om het te openen. - {{ url }} + Hun gegevens zijn toegevoegd aan het ledenoverzicht in het ledenadministratiesysteem.

Kameraadschappelijke groet, diff --git a/templates/email/text/contact_new_member.txt.twig b/templates/email/text/contact_new_member.txt.twig index 4de0851..ed653d2 100644 --- a/templates/email/text/contact_new_member.txt.twig +++ b/templates/email/text/contact_new_member.txt.twig @@ -1,13 +1,11 @@ r% extends 'email/text/layout.txt.twig' %} -{% set url = url('division', { division: member.division.name }) %} {% block content %} -Beste {{ member.division.contact.firstName }} {{ member.division.contact.lastName }}, +Beste {{ contact.getFullName }}, Onlangs heeft een nieuw lid zich aangemeld bij {{ organisatienaam }}: {{ member.getFullName }}. Hun lidmaatschap is zojuist goedgekeurd door het bestuur van {{ organisatienaam }}. Bij het aanmelden heeft dit lid aangegeven zich graag aan te sluiten bij de groep {{ member.division.name }}. -Hun gegevens zijn toegevoegd aan het ledenoverzicht in het ledenadministratiesysteem. Klik op de onderstaande link om het te openen. -{{ url }} +Hun gegevens zijn toegevoegd aan het ledenoverzicht in het ledenadministratiesysteem. Kameraadschappelijke groet, From 2f2ce6a001092cde8adc9fdac694fd719f0fa69d Mon Sep 17 00:00:00 2001 From: Gwildor Sok Date: Tue, 21 May 2024 21:44:23 +0200 Subject: [PATCH 2/2] [SCOUT] Hide approve member applications behind flag for contacts --- .env | 1 + config/services.yaml | 1 + src/Controller/Admin/DashboardController.php | 16 +++++++++++++--- .../Admin/MembershipApplicationCrud.php | 10 +++++++++- .../email/html/contact_new_member.html.twig | 2 +- templates/email/text/contact_new_member.txt.twig | 4 ++-- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 067e284..5f8b4b4 100644 --- a/.env +++ b/.env @@ -60,6 +60,7 @@ USE_MIDDLE_NAME=true CONTRIBUTION_ENABLED=true SEND_FRESH_MEMBER_EMAIL_TO_BOARD=true SEND_FRESH_MEMBER_EMAIL_TO_DIVISION_EMAIL=false +ENABLE_DIVISION_CONTACTS_CAN_APPROVE_NEW_MEMBERS=false # Set to https in production environment SECURE_SCHEME='http' diff --git a/config/services.yaml b/config/services.yaml index 2f830aa..1a2321f 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -17,6 +17,7 @@ parameters: app.sendFreshMemberEmailToBoard: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_BOARD)%' app.sendFreshMemberEmailToDivisionEmail: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_DIVISION_EMAIL)%' app.contributionEnabled: '%env(bool:CONTRIBUTION_ENABLED)%' + app.enableDivisionContactsCanApproveNewMembers: '%env(bool:ENABLE_DIVISION_CONTACTS_CAN_APPROVE_NEW_MEMBERS)%' router.request_context.scheme: '%env(SECURE_SCHEME)%' asset.request_context.secure: true diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index d1469c8..e1fecbd 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -49,7 +49,7 @@ public function configureCrud(): Crud { public function configureMenuItems(): iterable { - return [ + $items = [ MenuItem::linkToDashboard('Dashboard', 'fa fa-home'), MenuItem::section('Website')->setPermission('ROLE_ADMIN'), @@ -58,7 +58,15 @@ public function configureMenuItems(): iterable MenuItem::section('Administratie'), MenuItem::linkToCrud('Leden', 'fa fa-users', Member::class), MenuItem::linkToCrud('Steunleden', 'fa fa-users', SupportMember::class)->setPermission('ROLE_ADMIN'), - MenuItem::linkToCrud('Aanmeldingen', 'fa fa-user-plus', MembershipApplication::class), + ]; + + $membership_applications = MenuItem::linkToCrud('Aanmeldingen', 'fa fa-user-plus', MembershipApplication::class); + if (!$this->getParameter('app.enableDivisionContactsCanApproveNewMembers')) { + $membership_applications->setPermission('ROLE_ADMIN'); + } + + array_push($items, + $membership_applications, MenuItem::linkToCrud('Groepen', 'fa fa-building', Division::class)->setPermission('ROLE_ADMIN'), MenuItem::linkToCrud('Lidmaatschapstypes', 'fa fa-building', MembershipStatus::class)->setPermission('ROLE_ADMIN'), @@ -69,6 +77,8 @@ public function configureMenuItems(): iterable MenuItem::linkToRoute('Home', 'fa fa-arrow-left', 'member_home'), MenuItem::linkToRoute('Statistieken', 'fa fa-bar-chart', 'admin_statistics')->setPermission('ROLE_ADMIN'), MenuItem::linkToLogout('Uitloggen', 'fa fa-lock') - ]; + ); + + return $items; } } diff --git a/src/Controller/Admin/MembershipApplicationCrud.php b/src/Controller/Admin/MembershipApplicationCrud.php index 90e8f9a..b589f96 100644 --- a/src/Controller/Admin/MembershipApplicationCrud.php +++ b/src/Controller/Admin/MembershipApplicationCrud.php @@ -56,11 +56,19 @@ public static function getEntityFqcn(): string public function configureCrud(Crud $crud): Crud { - return $crud + $crud ->setEntityLabelInSingular('aanmelding') ->setEntityLabelInPlural('Lidmaatschapsaanmeldingen') ->setSearchFields(['id', 'firstName', 'lastName', 'email', 'phone', 'city', 'postCode']) ; + + if ($this->getParameter('app.enableDivisionContactsCanApproveNewMembers')) { + $crud->setEntityPermission('ROLE_DIVISION_CONTACT'); + } else { + $crud->setEntityPermission('ROLE_ADMIN'); + } + + return $crud; } public function configureActions(Actions $actions): Actions diff --git a/templates/email/html/contact_new_member.html.twig b/templates/email/html/contact_new_member.html.twig index 36d5b85..e7f4ee9 100644 --- a/templates/email/html/contact_new_member.html.twig +++ b/templates/email/html/contact_new_member.html.twig @@ -1,7 +1,7 @@ {% extends 'email/html/layout.html.twig' %} {% block content %}

- Beste {{ contact.getFullName }}, + Beste {{ contact.getFirstName }},

Onlangs heeft een nieuw lid zich aangemeld bij {{ organisatienaam }}: {{ member.getFullName }}. diff --git a/templates/email/text/contact_new_member.txt.twig b/templates/email/text/contact_new_member.txt.twig index ed653d2..342525e 100644 --- a/templates/email/text/contact_new_member.txt.twig +++ b/templates/email/text/contact_new_member.txt.twig @@ -1,6 +1,6 @@ -r% extends 'email/text/layout.txt.twig' %} +{% extends 'email/text/layout.txt.twig' %} {% block content %} -Beste {{ contact.getFullName }}, +Beste {{ contact.getFirstName }}, Onlangs heeft een nieuw lid zich aangemeld bij {{ organisatienaam }}: {{ member.getFullName }}. Hun lidmaatschap is zojuist goedgekeurd door het bestuur van {{ organisatienaam }}. Bij het aanmelden heeft dit lid aangegeven zich graag aan te sluiten bij de groep {{ member.division.name }}.