Skip to content
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

[SCOUT] Make signup approval work again #194

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 13 additions & 3 deletions src/Controller/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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)->setPermission('ROLE_ADMIN'),
];

$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'),

Expand All @@ -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;
}
}
20 changes: 15 additions & 5 deletions src/Controller/Admin/MembershipApplicationCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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
Expand Down Expand Up @@ -157,11 +165,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,
]),
);
Expand Down
6 changes: 2 additions & 4 deletions templates/email/html/contact_new_member.html.twig
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{% extends 'email/html/layout.html.twig' %}
{% set url = url('division', { division: member.division.name }) %}
{% block content %}
<p>
Beste {{ member.division.contact.firstName }} {{ member.division.contact.lastName }},
Beste {{ contact.getFirstName }},
</p>
<p>
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 }}.
</p>
<p>
Hun gegevens zijn toegevoegd aan het ledenoverzicht in het ledenadministratiesysteem. Klik op de onderstaande link om het te openen.
<a href="{{ url }}">{{ url }}</a>
Hun gegevens zijn toegevoegd aan het ledenoverzicht in het ledenadministratiesysteem.
</p>
<p>
Kameraadschappelijke groet,
Expand Down
8 changes: 3 additions & 5 deletions templates/email/text/contact_new_member.txt.twig
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
r% extends 'email/text/layout.txt.twig' %}
{% set url = url('division', { division: member.division.name }) %}
{% extends 'email/text/layout.txt.twig' %}
{% block content %}
Beste {{ member.division.contact.firstName }} {{ member.division.contact.lastName }},
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 }}.

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,

Expand Down
Loading