Skip to content

Commit

Permalink
Merge branch 'main' into 141-emails
Browse files Browse the repository at this point in the history
  • Loading branch information
pingiun authored May 19, 2024
2 parents d3952a2 + 7058e92 commit 934fd68
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 18 deletions.
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'
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,35 @@ ID will be incremented because of auto-increment options in the database.

Go to `http://localhost:8080/` and you should be greeted by the MijnRood login page.

You can log in with `[email protected]` as email, and `admin` as password.
Look at `src/DataFixtures/` to see an overview of all test data, including other accounts.
## Local test login data:

Admin level:
- Name: `Admin de Baas`
- E-mail: `[email protected]`
- Password: `admin`

Group head level:
- Name: `Jan Jansen`
- E-mail: `[email protected]`
- Password: `contact`
- Member off: `Noorderhaaks`
- Head off: `Noorderhaaks`

Member level:
- Name: `Henk de Vries`
- E-mail: `[email protected]`
- Password: `new_member`
- Member off: `Nooderhaaks`

## Server deployment

To deploy updates on the server:
```
sudo -u deploy -i
docker compose -f docker/prod/docker-compose.yml --env-file .env.local down
git pull
docker compose -f docker/prod/docker-compose.yml --env-file .env.local up --build -d
```

## Extra configuration

Expand Down
1 change: 1 addition & 0 deletions assets/style/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
display: block;

a {
color: black;
font-size: 24px;
font-family: @font-titles;
text-transform: uppercase;
Expand Down
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.useMiddleName: '%env(bool:USE_MIDDLE_NAME)%'
app.sendFreshMemberEmailToBoard: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_BOARD)%'
app.sendFreshMemberEmailToContactPeople: '%env(bool:SEND_FRESH_MEMBER_EMAIL_TO_CONTACT_PEOPLE)%'
app.contributionEnabled: '%env(bool:CONTRIBUTION_ENABLED)%'
router.request_context.scheme: '%env(SECURE_SCHEME)%'
asset.request_context.secure: true

Expand Down
24 changes: 18 additions & 6 deletions src/Controller/Admin/MemberCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class MemberCrud extends AbstractCrudController
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.division IN (:division)')->setParameter('division', $this->getUser()->getManagedDivisions());
}
$division = $this->getUser()->getDivision();
$response->andWhere('entity.division = :division')->setParameter('division', $division);

return $response;
}

Expand Down Expand Up @@ -104,7 +104,15 @@ public function export(AdminContext $adminContext): BinaryFileResponse
$members = $this->getDoctrine()->getRepository(Member::class)->findAll();
}
else {
$members = $this->getDoctrine()->getRepository(Member::class)->findBy(['division' => $this->getUser()->getDivision()]);
// Just using the division objects should work, but for some reason
// it gave an error that the PersistentCollection could not be cast
// to int. So just collecting the id's first fixes this.
$divisions = [];
foreach ($this->getUser()->getManagedDivisions() as $division) {
$divisions[] = $division->getId();
}

$members = $this->getDoctrine()->getRepository(Member::class)->findBy(['division' => $divisions]);
}

$i = 2;
Expand Down Expand Up @@ -187,7 +195,11 @@ public function configureFields(string $pageName): iterable

if ($isAdmin) {
$fields[] = AssociationField::new('currentMembershipStatus', 'Lidmaatschapstype');
$fields[] = AssociationField::new('division', 'Afdeling');
}

$fields[] = AssociationField::new('division', 'Afdeling');

if ($isAdmin) {
$fields[] = BooleanField::new('isAdmin', 'Toegang tot administratie')
->hideOnIndex();
}
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 @@ -41,6 +41,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 @@ -61,7 +62,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 @@ -73,6 +75,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 @@ -83,7 +86,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 @@ -326,7 +330,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 @@ -363,7 +367,8 @@ public function details(Request $request, UserPasswordEncoderInterface $password
'form' => $form->createView(),
'formPassword' => $formPassword->createView(),
'success' => $success,
'successPassword' => $successPassword
'successPassword' => $successPassword,
'contributionEnabled' => $contributionEnabled,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Division.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Division {
private string $name = '';

/**
* @ORM\ManyToMany(targetEntity="Member")
* @ORM\ManyToMany(targetEntity="Member", inversedBy="managed_divisions")
* @ORM\JoinTable(name="division_member")
*/
private Collection $contacts;
Expand Down
8 changes: 8 additions & 0 deletions src/Entity/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ class Member implements UserInterface {
*/
private ?Division $division = null;

/**
* @ORM\ManyToMany(targetEntity="Division", inversedBy="contacts")
* @ORM\JoinTable(name="division_member")
*/
private Collection $managed_divisions;

/**
* @ORM\Column(type="date", nullable=true)
*/
Expand Down Expand Up @@ -229,6 +235,8 @@ public function setDateOfBirth(?DateTime $dateOfBirth): void { $this->dateOfBirt
public function getDivision(): ?Division { return $this->division; }
public function setDivision(?Division $division): void { $this->division = $division; }

public function getManagedDivisions(): Collection { return $this->managed_divisions; }

public function getRegistrationTime(): ?DateTime { return $this->registrationTime; }
public function setRegistrationTime(?DateTime $registrationTime): void { $this->registrationTime = $registrationTime; }

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

0 comments on commit 934fd68

Please sign in to comment.