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

[BDE] update event registration template email #10151

Merged
merged 1 commit into from Apr 27, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Expand Up @@ -158,3 +158,5 @@ NATIONAL_EVENT_TICKET_API_KEY=123
SYSTEMPAY_KEY=123
SYSTEMPAY_SITE_ID=123
SYSTEMPAY_MODE=TEST

VOX_HOST=vox.code
4 changes: 4 additions & 0 deletions config/routes.yaml
Expand Up @@ -316,6 +316,10 @@ besoindeurope_site:
host: "%besoindeurope_host%"
path: "/"

vox_app:
host: "%vox_host%"
path: "/"

vox_app_redirect:
methods: GET
host: "%user_besoindeurope_host%"
Expand Down
1 change: 1 addition & 0 deletions config/services.yaml
Expand Up @@ -18,6 +18,7 @@ parameters:
avecvous_host: "%env(AVECVOUS_HOST)%"
national_event_host: "%env(NATIONAL_EVENT_HOST)%"
user_besoindeurope_host: "%env(USER_BESOINDEUROPE_HOST)%"
vox_host: "%env(VOX_HOST)%"
besoindeurope_host: "%env(BESOINDEUROPE_HOST)%"
avecvous_qrcode_host: "%env(AVECVOUS_QRCODE_HOST)%"
procuration_host: "%env(PROCURATION_HOST)%"
Expand Down
188 changes: 0 additions & 188 deletions features/api/events.feature
Expand Up @@ -1415,108 +1415,6 @@ Feature:
"editable": true
}
"""
And I should have 1 email
And I should have 1 email "RenaissanceEventUpdateMessage" for "francis.brioul@yahoo.com" with payload:
"""
{
"template_name": "renaissance-event-update",
"template_content": [],
"message": {
"subject": "Un événement auquel vous participez a été mis à jour",
"from_email": "no-reply@parti-renaissance.fr",
"global_merge_vars": [
{
"name": "event_name",
"content": "Nouvel événement online"
},
{
"name": "event_url",
"content": "http://test.renaissance.code/espace-adherent/evenements/2022-12-12-nouvel-evenement-online/afficher"
},
{
"name": "event_date",
"content": "lundi 12 décembre 2022"
},
{
"name": "event_hour",
"content": "10h30"
},
{
"name": "event_address",
"content": "dammarie-les-lys, 77190 dammarie-les-lys"
},
{
"name": "calendar_url",
"content": "http://test.renaissance.code/espace-adherent/evenements/2022-12-12-nouvel-evenement-online/ical"
}
],
"merge_vars": [
{
"rcpt": "referent@en-marche-dev.fr",
"vars": [
{
"name": "first_name",
"content": "Referent"
}
]
},
{
"rcpt": "francis.brioul@yahoo.com",
"vars": [
{
"name": "first_name",
"content": "Francis"
}
]
},
{
"rcpt": "simple-user@example.ch",
"vars": [
{
"name": "first_name",
"content": "Simple"
}
]
},
{
"rcpt": "marie.claire@test.com",
"vars": [
{
"name": "first_name",
"content": "Marie"
}
]
}
],
"headers": {
"Reply-To": "referent@en-marche-dev.fr"
},
"from_name": "Renaissance",
"to": [
{
"email": "referent@en-marche-dev.fr",
"type": "to",
"name": "Referent Referent"
},
{
"email": "francis.brioul@yahoo.com",
"type": "to",
"name": "Francis Brioul"
},
{
"email": "simple-user@example.ch",
"type": "to",
"name": "Simple User"
},
{
"email": "marie.claire@test.com",
"type": "to",
"name": "Marie CLAIRE"
}
]
}
}
"""
Examples:
| user | scope |
| referent@en-marche-dev.fr | referent |
Expand All @@ -1526,92 +1424,6 @@ Feature:
Given I am logged with "<user>" via OAuth client "JeMengage Web" with scope "jemengage_admin"
When I send a "PUT" request to "/api/v3/events/5cab27a7-dbb3-4347-9781-566dad1b9eb5/cancel?scope=<scope>"
Then the response status code should be 200
And I should have 1 email
And I should have 1 email "EventCancellationMessage" for "francis.brioul@yahoo.com" with payload:
"""
{
"template_name": "event-cancellation",
"template_content": [],
"message": {
"subject": "L'événement @string@Nouvel événement online@string@ a été annulé.",
"from_email": "contact@en-marche.fr",
"global_merge_vars": [
{
"name": "event_name",
"content": "Nouvel événement online"
},
{
"name": "event_slug",
"content": "http://test.enmarche.code/evenements"
}
],
"merge_vars": [
{
"rcpt": "referent@en-marche-dev.fr",
"vars": [
{
"name": "target_firstname",
"content": "Referent"
}
]
},
{
"rcpt": "francis.brioul@yahoo.com",
"vars": [
{
"name": "target_firstname",
"content": "Francis"
}
]
},
{
"rcpt": "simple-user@example.ch",
"vars": [
{
"name": "target_firstname",
"content": "Simple"
}
]
},
{
"rcpt": "marie.claire@test.com",
"vars": [
{
"name": "target_firstname",
"content": "Marie"
}
]
}
],
"headers": {
"Reply-To": "referent@en-marche-dev.fr"
},
"from_name": "La République En Marche !",
"to": [
{
"email": "referent@en-marche-dev.fr",
"type": "to",
"name": "Referent Referent"
},
{
"email": "francis.brioul@yahoo.com",
"type": "to",
"name": "Francis Brioul"
},
{
"email": "simple-user@example.ch",
"type": "to",
"name": "Simple User"
},
{
"email": "marie.claire@test.com",
"type": "to",
"name": "Marie CLAIRE"
}
]
}
}
"""
Examples:
| user | scope |
| referent@en-marche-dev.fr | referent |
Expand Down
5 changes: 0 additions & 5 deletions src/Entity/Event/CommitteeEvent.php
Expand Up @@ -155,11 +155,6 @@ public function needNotifyForRegistration(): bool
return true;
}

public function needNotifyForCancellation(): bool
{
return true;
}

public function getContentContainingDocuments(): string
{
return (string) $this->description;
Expand Down
5 changes: 0 additions & 5 deletions src/Entity/Event/DefaultEvent.php
Expand Up @@ -20,9 +20,4 @@ public function getType(): string
{
return EventTypeEnum::TYPE_DEFAULT;
}

public function needNotifyForCancellation(): bool
{
return true;
}
}
6 changes: 3 additions & 3 deletions src/Event/EventRegistrationSubscriber.php
Expand Up @@ -5,7 +5,7 @@
use App\AppCodeEnum;
use App\Events;
use App\Mailer\MailerService;
use App\Mailer\Message\JeMengage\JeMengageEventRegistrationConfirmationMessage;
use App\Mailer\Message\BesoinDEurope\BesoinDEuropeEventRegistrationConfirmationMessage;
use App\Mailer\Message\Renaissance\RenaissanceEventRegistrationConfirmationMessage;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
Expand Down Expand Up @@ -37,9 +37,9 @@ public function sendRegistrationEmail(EventRegistrationEvent $event): void
$registration = $event->getRegistration();

if (AppCodeEnum::isJeMengage($registration->getSource())) {
$message = JeMengageEventRegistrationConfirmationMessage::createFromRegistration(
$message = BesoinDEuropeEventRegistrationConfirmationMessage::createFromRegistration(
$registration,
$this->generateUrl('app_committee_event_show', ['slug' => $event->getSlug()])
$this->generateUrl('vox_app').'/event-detail?id='.$registration->getEvent()->getUuidAsString(),
);
} else {
$message = RenaissanceEventRegistrationConfirmationMessage::createFromRegistration(
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/SendEventUpdateNotificationListener.php
Expand Up @@ -86,7 +86,7 @@ private function doPreUpdate(BaseEvent $event): void

private function doPostUpdate(BaseEvent $event): void
{
if (!$this->matchChanges($event)) {
if (true || !$this->matchChanges($event)) {
return;
}

Expand Down
@@ -0,0 +1,45 @@
<?php

namespace App\Mailer\Message\BesoinDEurope;

use App\Entity\Event\EventRegistration;
use App\Mailer\Message\Renaissance\AbstractRenaissanceMessage;
use Ramsey\Uuid\Uuid;

class BesoinDEuropeEventRegistrationConfirmationMessage extends AbstractRenaissanceMessage
{
public static function createFromRegistration(EventRegistration $registration, string $eventLink): self
{
$event = $registration->getEvent();
$firstName = $registration->getFirstName();

return new self(
Uuid::uuid4(),
$registration->getEmailAddress(),
$firstName,
'',
static::getTemplateVars(
$event->getName(),
$event->getOrganizerName(),
$eventLink
),
static::getRecipientVars($firstName)
);
}

private static function getTemplateVars(string $eventName, string $organizerName, string $eventLink): array
{
return [
'event_name' => self::escape($eventName),
'event_organiser' => self::escape($organizerName),
'event_link' => $eventLink,
];
}

private static function getRecipientVars(string $firstName): array
{
return [
'first_name' => self::escape($firstName),
];
}
}
2 changes: 1 addition & 1 deletion templates/besoindeurope/donation/form.html.twig
Expand Up @@ -141,7 +141,7 @@
}) }}

<div class="w-full re-field-frame !h-auto cursor-pointer" x-on:click="dom('.frc-button')?.click()">
{% include 'renaissance/partials/friendly-captcha.html.twig' with {friendly_captcha_site_key: friendly_captcha_europe_site_key} %}
{% include 'renaissance/partials/friendly-captcha.html.twig' %}
</div>
<twig:ReButton
color="green"
Expand Down
2 changes: 1 addition & 1 deletion templates/besoindeurope/inscription/form.html.twig
Expand Up @@ -68,7 +68,7 @@
}) }}

<div class="w-full re-field-frame !h-auto cursor-pointer" x-on:click="dom('.frc-button')?.click()">
{% include 'renaissance/partials/friendly-captcha.html.twig' with {friendly_captcha_site_key: friendly_captcha_europe_site_key} %}
{% include 'renaissance/partials/friendly-captcha.html.twig' %}
</div>

<twig:ReButton
Expand Down
4 changes: 0 additions & 4 deletions tests/Controller/Api/Event/EventControllerTest.php
Expand Up @@ -7,7 +7,6 @@
use App\DataFixtures\ORM\LoadClientData;
use App\Entity\Event\BaseEvent;
use App\Event\EventTypeEnum;
use App\Mailer\Message\JeMengage\JeMengageEventUpdateMessage;
use App\OAuth\Model\GrantTypeEnum;
use App\OAuth\Model\Scope;
use PHPUnit\Framework\Attributes\Group;
Expand Down Expand Up @@ -75,8 +74,5 @@ public function testAReferentCanCreateAnEventInJme(): void

self::assertSame('My best edited event !', $response['name']);
self::assertSame('online', $response['mode']);

$this->assertCountMails(1, JeMengageEventUpdateMessage::class);
$this->assertMail(JeMengageEventUpdateMessage::class, 'president-ad@renaissance-dev.fr', ['template_name' => 'je-mengage-event-update']);
}
}
10 changes: 0 additions & 10 deletions tests/Controller/EnMarche/EventManagerControllerTest.php
Expand Up @@ -5,9 +5,7 @@
use App\DataFixtures\ORM\LoadCommitteeEventData;
use App\DataFixtures\ORM\LoadEventCategoryData;
use App\Entity\Event\CommitteeEvent;
use App\Mailer\Message\EventCancellationMessage;
use App\Mailer\Message\EventContactMembersMessage;
use App\Mailer\Message\EventUpdateMessage;
use Cake\Chronos\Chronos;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
Expand Down Expand Up @@ -99,7 +97,6 @@ public function testOrganizerCanEditEvent()
]));

$this->assertStatusCode(Response::HTTP_FOUND, $this->client);
$this->assertCountMails(1, EventUpdateMessage::class);

// Follow the redirect and check the adherent can see the committee page
$crawler = $this->client->followRedirect();
Expand Down Expand Up @@ -131,13 +128,6 @@ public function testOrganizerCanCancelEvent()

$this->assertStatusCode(Response::HTTP_OK, $this->client);
$this->seeFlashMessage($crawler, 'L\'événement a bien été annulé.');

$messages = $this->getEmailRepository()->findMessages(EventCancellationMessage::class);
/** @var EventCancellationMessage $message */
$message = array_shift($messages);

// Two mails have been sent
$this->assertCount(2, $message->getRecipients());
}

public function testCommitteeHostCanEditEvent()
Expand Down