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

Add ability to make contribution optional #182

Merged
merged 1 commit into from
May 19, 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 @@ -58,6 +58,7 @@ ORG_LOGO='assets/image/logo.png'
PRIVACY_POLICY_URL='https://roodjongeren.nl/privacybeleid/'
LISTMONK_URL='https://listmonk.roodjongeren.nl/admin'
USE_MIDDLE_NAME=true
CONTRIBUTION_ENABLED=true

# 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 @@ -14,6 +14,7 @@ parameters:
app.privacyPolicyUrl: '%env(PRIVACY_POLICY_URL)%'
app.listmonkUrl: '%env(string:LISTMONK_URL)%'
app.useMiddleName: '%env(bool:USE_MIDDLE_NAME)%'
app.contributionEnabled: '%env(bool:CONTRIBUTION_ENABLED)%'
router.request_context.scheme: '%env(SECURE_SCHEME)%'
asset.request_context.secure: true

Expand Down
11 changes: 8 additions & 3 deletions src/Controller/DocumentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function documents(Request $requset, $folderId): Response {
'choices' => $repoFolders->findAll(),
'action' => $this->generateUrl('member_documents_move')
]);
$contributionEnabled = $this->getParameter('app.contributionEnabled');

return $this->render('user/documents.html.twig', [
'folders' => $folders,
Expand All @@ -43,7 +44,8 @@ public function documents(Request $requset, $folderId): Response {

'uploadForm' => $uploadForm->createView(),
'newFolderForm' => $newFolderForm->createView(),
'moveForm' => $moveForm->createView()
'moveForm' => $moveForm->createView(),
'contributionEnabled' => $contributionEnabled,
]);
}

Expand Down Expand Up @@ -93,7 +95,8 @@ public function createFolder(Request $request, $folderId): Response {
return $this->json(['status' => 'success', 'id' => $newFolder->getId()]);
}

return $this->redirectToRoute('member_documents', ['folderId' => $newFolder->getId()]);
$contributionEnabled = $this->getParameter('app.contributionEnabled');
return $this->redirectToRoute('member_documents', ['folderId' => $newFolder->getId(), 'contributionEnabled' => $contributionEnabled]);
}

throw $this->createNotFoundException();
Expand Down Expand Up @@ -157,8 +160,10 @@ public function upload(Request $request, $folderId): Response {
]);
}

$contributionEnabled = $this->getParameter('app.contributionEnabled');
return $this->redirectToRoute('member_documents', [
'folderId' => $folder ? $folder->getId() : ''
'folderId' => $folder ? $folder->getId() : '',
'contributionEnabled' => $contributionEnabled,
]);
}

Expand Down
13 changes: 9 additions & 4 deletions src/Controller/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function memberAcceptPersonalDetails(Request $request): Response {
$member = $this->getUser();
$orgName = $this->getParameter('app.organizationName');
$privacyPolicyUrl = $this->getParameter('app.privacyPolicyUrl');
$contributionEnabled = $this->getParameter('app.contributionEnabled');
$form = $this->createFormBuilder($member)
->add('acceptUsePersonalInformation', null, [
'label' => "Ik ga ermee akkoord dat $orgName mijn persoonsgegevens opslaat in haar ledenadministratie, zoals beschreven in het <a href='$privacyPolicyUrl'>privacybeleid</a>.",
Expand All @@ -57,7 +58,8 @@ public function memberAcceptPersonalDetails(Request $request): Response {
}

return $this->render('user/privacy-policy.html.twig', [
'form' => $form->createView()
'form' => $form->createView(),
'contributionEnabled' => $contributionEnabled,
]);
}

Expand All @@ -69,6 +71,7 @@ public function home(Request $request): Response {
if (!$member->getAcceptUsePersonalInformation())
return $this->memberAcceptPersonalDetails($request);

$contributionEnabled = $this->getParameter('app.contributionEnabled');
$events = $this->getDoctrine()->getRepository(Event::class)->createQueryBuilder('e')
->where('e.division IS NULL or e.division = ?1')
->andWhere('e.timeEnd > ?2')
Expand All @@ -79,7 +82,8 @@ public function home(Request $request): Response {
->getResult();

return $this->render('user/home.html.twig', [
'events' => $events
'events' => $events,
'contributionEnabled' => $contributionEnabled,
]);
}

Expand Down Expand Up @@ -264,7 +268,7 @@ public function details(Request $request, UserPasswordEncoderInterface $password
$member = $this->getUser();
if (!$member->getAcceptUsePersonalInformation())
return $this->memberAcceptPersonalDetails($request);

$contributionEnabled = $this->getParameter('app.contributionEnabled');
$form = $this->createForm(MemberDetailsType::class, $member);
$revision = new MemberDetailsRevision($member, true);
$success = false;
Expand Down Expand Up @@ -301,7 +305,8 @@ public function details(Request $request, UserPasswordEncoderInterface $password
'form' => $form->createView(),
'formPassword' => $formPassword->createView(),
'success' => $success,
'successPassword' => $successPassword
'successPassword' => $successPassword,
'contributionEnabled' => $contributionEnabled,
]);
}

Expand Down
3 changes: 2 additions & 1 deletion templates/user/details.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

{{ form_end(formPassword) }}
</div>

{% if contributionEnabled %}
<div class="contributions">
<h1>Contributie</h1>

Expand Down Expand Up @@ -158,5 +158,6 @@
</tbody>
</table>
</div>
{% endif %}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion templates/user/layout/members.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% endblock %}

{% block body %}
{% if not app.user.contributionPaidAutomatically %}
{% if not app.user.contributionPaidAutomatically and contributionEnabled %}
<div id="nagbar">
<span>Je hebt nog geen automatisch incasso ingesteld! Stel dit in op de <a href="{{ url('member_details') }}">gegevens</a> pagina.</span>
</div>
Expand Down
Loading