From 20ba2e73b4b49b2eb1b47c35f05a22a5640bb1fe Mon Sep 17 00:00:00 2001 From: Dimitri Gritsajuk Date: Thu, 2 Jan 2025 18:19:23 +0100 Subject: [PATCH] Remove useless adherent column --- config/packages/security.yaml | 4 +- migrations/Version20250102173536.php | 19 +++++ .../AdherentExtractCommandHandler.php | 6 +- .../Unregistration/UnregistrationFactory.php | 4 +- src/AdherentProfile/AdherentProfile.php | 1 + .../Handler/CreateAccountCommandHandler.php | 1 - src/Admin/DonationAdmin.php | 1 - .../RemindActivatedMembershipCommand.php | 1 - src/Command/SendAdhesionReportCommand.php | 5 +- .../SendNewMembershipNotificationCommand.php | 2 - src/Controller/Api/AdherentController.php | 2 +- .../GetAdherentMessageStatusController.php | 2 +- src/Controller/Api/ProfileController.php | 10 +-- .../AbstractStatisticsController.php | 13 ---- .../Api/Statistics/AdherentsController.php | 33 --------- src/Controller/Api/UserController.php | 2 +- .../AdherentProfile/FunnelController.php | 2 +- .../EnMarche/CommitteeController.php | 1 - src/Controller/EnMarche/EventController.php | 2 +- .../EnMarche/InvitationController.php | 2 +- src/Controller/EnMarche/MyVoteController.php | 23 ------ src/Controller/EnMarche/UserController.php | 7 +- .../NotificationPreferencesController.php | 2 +- src/Entity/Adherent.php | 23 ------ src/Entity/Jecoute/JemarcheDataSurvey.php | 4 +- src/Membership/AdherentFactory.php | 9 +-- .../Admin/AdherentCreateCommandHandler.php | 1 - src/Repository/AdherentRepository.php | 21 +----- .../Voter/AdherentUnregistrationVoter.php | 4 -- src/Subscription/SubscriptionHandler.php | 6 +- src/Twig/AdherentExtension.php | 3 - src/Twig/AdherentRuntime.php | 39 ----------- templates/adherent/my_vote.html.twig | 70 ------------------- templates/adherent_profile/_layout.html.twig | 2 +- templates/base.html.twig | 1 - templates/committee/_sidebar.html.twig | 6 +- templates/committee/show.html.twig | 8 +-- templates/committee/timeline/_feed.html.twig | 2 +- .../committee/timeline/_message.html.twig | 2 +- .../_dropdown_user_mobile.html.twig | 18 +---- templates/components/_nav_desktop.html.twig | 2 +- templates/events/attend.html.twig | 2 +- .../EnMarche/UnregistrationControllerTest.php | 6 +- translations/messages+intl-icu.fr.yml | 2 - 44 files changed, 65 insertions(+), 311 deletions(-) create mode 100644 migrations/Version20250102173536.php delete mode 100644 src/Controller/Api/Statistics/AbstractStatisticsController.php delete mode 100644 src/Controller/Api/Statistics/AdherentsController.php delete mode 100644 src/Controller/EnMarche/MyVoteController.php delete mode 100644 templates/adherent/my_vote.html.twig diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 961143e2fa3..fbada85949a 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -506,7 +506,7 @@ security: access_control: - { path: '^/parametres', roles: [ROLE_USER] } - - { path: '^/espace-adherent', roles: [ROLE_ADHERENT] } + - { path: '^/espace-adherent', roles: [ROLE_USER] } - { host: '%admin_renaissance_host%', path: '^/login/(2fa|logout)', @@ -528,7 +528,7 @@ security: roles: [ROLE_ADMIN_DASHBOARD], } - { path: '^/membre/.*', roles: [IS_AUTHENTICATED_REMEMBERED] } - - { path: '^/elections/.+', roles: [ROLE_ADHERENT] } + - { path: '^/elections/.+', roles: [ROLE_USER] } - { path: '^/(adhesion|don|espace-elus)', allow_if: "not is_granted('ROLE_ADMIN_DASHBOARD')", diff --git a/migrations/Version20250102173536.php b/migrations/Version20250102173536.php new file mode 100644 index 00000000000..6728c0b529a --- /dev/null +++ b/migrations/Version20250102173536.php @@ -0,0 +1,19 @@ +addSql('ALTER TABLE adherents DROP adherent'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE adherents ADD adherent TINYINT(1) DEFAULT 0 NOT NULL'); + } +} diff --git a/src/Adherent/AdherentExtractCommandHandler.php b/src/Adherent/AdherentExtractCommandHandler.php index 0460ea4c520..7c0c4e6c1c4 100644 --- a/src/Adherent/AdherentExtractCommandHandler.php +++ b/src/Adherent/AdherentExtractCommandHandler.php @@ -87,12 +87,8 @@ protected function computeRow(array $row, string $email, array $fields): array case AdherentExtractCommand::FIELD_SOURCE: if ($adherent->isRenaissanceAdherent()) { $source = 'renaissance_adherent'; - } elseif ($adherent->isRenaissanceSympathizer()) { - $source = 'renaissance_sympathizer'; - } elseif ($adherent->isAdherent()) { - $source = 'enmarche_adherent'; } else { - $source = 'enmarche_user'; + $source = 'renaissance_sympathizer'; } $row[$this->translateField($field)] = $this->translator->trans(\sprintf('adherent.source.%s', $source)); diff --git a/src/Adherent/Unregistration/UnregistrationFactory.php b/src/Adherent/Unregistration/UnregistrationFactory.php index da7fb065f92..04ac1ea9cac 100644 --- a/src/Adherent/Unregistration/UnregistrationFactory.php +++ b/src/Adherent/Unregistration/UnregistrationFactory.php @@ -18,7 +18,7 @@ public static function createFromUnregistrationCommandAndAdherent( $command->getComment(), $adherent->getRegisteredAt(), $adherent->getPostAddress()->getPostalCode(), - $adherent->isAdherent(), + $adherent->isRenaissanceAdherent(), $adherent->isRenaissanceUser(), $command->getExcludedBy() ); @@ -33,7 +33,7 @@ public static function createFromAdherent(Adherent $adherent, ?string $comment = $comment, $adherent->getRegisteredAt(), $adherent->getPostAddress()->getPostalCode(), - $adherent->isAdherent(), + $adherent->isRenaissanceAdherent(), $adherent->isRenaissanceUser(), ); } diff --git a/src/AdherentProfile/AdherentProfile.php b/src/AdherentProfile/AdherentProfile.php index af0fb019b27..65fa1db1625 100644 --- a/src/AdherentProfile/AdherentProfile.php +++ b/src/AdherentProfile/AdherentProfile.php @@ -166,6 +166,7 @@ class AdherentProfile implements MembershipInterface #[Groups(['profile_write'])] public ?string $partyMembership = null; + // Used to skip nationality field validation when user is a sympathizer @see nationality field public bool $isAdherent = false; public function __construct() diff --git a/src/Adhesion/Handler/CreateAccountCommandHandler.php b/src/Adhesion/Handler/CreateAccountCommandHandler.php index 54d0d11938f..f524bf8b097 100644 --- a/src/Adhesion/Handler/CreateAccountCommandHandler.php +++ b/src/Adhesion/Handler/CreateAccountCommandHandler.php @@ -63,7 +63,6 @@ public function __invoke(CreateAccountCommand $command): CreateAdherentResult 3 => MembershipTypeEnum::OTHER, }; - $currentUser->join(); $currentUser->setV2(true); $currentUser->finishAdhesionStep(AdhesionStepEnum::MAIN_INFORMATION); diff --git a/src/Admin/DonationAdmin.php b/src/Admin/DonationAdmin.php index 07377f27c12..09674d2d357 100644 --- a/src/Admin/DonationAdmin.php +++ b/src/Admin/DonationAdmin.php @@ -671,7 +671,6 @@ private function handleAdherentMembership(Donation $donation): void && ($adherent = $donation->getDonator()->getAdherent()) ) { $adherent->donatedForMembership($donation->getDonatedAt()); - $adherent->join(); $adherent->setSource(MembershipSourceEnum::RENAISSANCE); $adherent->setPapUserRole(true); } diff --git a/src/Command/RemindActivatedMembershipCommand.php b/src/Command/RemindActivatedMembershipCommand.php index 1fa53f09e07..2005ec09566 100644 --- a/src/Command/RemindActivatedMembershipCommand.php +++ b/src/Command/RemindActivatedMembershipCommand.php @@ -67,7 +67,6 @@ private function findActivated(\DateTime $from, int $limit): array { return $this->adherentRepository ->createQueryBuilder('adherent') - ->where('adherent.adherent = 1') ->andWhere('adherent.membershipRemindedAt IS NULL') ->andWhere('adherent.lastMembershipDonation IS NULL') ->andWhere('adherent.registeredAt < :date') diff --git a/src/Command/SendAdhesionReportCommand.php b/src/Command/SendAdhesionReportCommand.php index 93d62b42210..063b8d14329 100644 --- a/src/Command/SendAdhesionReportCommand.php +++ b/src/Command/SendAdhesionReportCommand.php @@ -97,7 +97,7 @@ private function getAdherentsToNotify(): array { return $this->repository->createQueryBuilder('a') ->leftJoin('a.zoneBasedRoles', 'zoneBasedRole') - ->where('a.status = :status AND a.adherent = :true') + ->where('a.status = :status') ->andWhere('zoneBasedRole.type = :deputy') ->setParameters([ 'status' => Adherent::ENABLED, @@ -154,11 +154,10 @@ private function createCountQueryBuilder(int $interval): QueryBuilder return $this->repository->createQueryBuilder('a') ->select('COUNT(DISTINCT a.id)') - ->where('a.status = :status AND a.adherent = :true') + ->where('a.status = :status') ->andWhere('a.activatedAt >= :start_date AND a.activatedAt <= :end_date') ->setParameters([ 'status' => Adherent::ENABLED, - 'true' => true, 'start_date' => $startDate->format('Y-m-d 00:00:00'), 'end_date' => $endDate->format('Y-m-d 23:59:59'), ]) diff --git a/src/Command/SendNewMembershipNotificationCommand.php b/src/Command/SendNewMembershipNotificationCommand.php index 14a0d751d50..889f056c56c 100644 --- a/src/Command/SendNewMembershipNotificationCommand.php +++ b/src/Command/SendNewMembershipNotificationCommand.php @@ -79,14 +79,12 @@ private function getManagersToNotify(): array 'zone_based_role.adherent = adherent AND zone_based_role.type = :type_pad' ) ->andWhere('adherent.status = :status') - ->andWhere('adherent.adherent = :true') ->andWhere((new Orx()) ->add('animator_committee.id IS NOT NULL') ->add('zone_based_role.id IS NOT NULL') ) ->setParameters([ 'status' => Adherent::ENABLED, - 'true' => true, 'type_pad' => ScopeEnum::PRESIDENT_DEPARTMENTAL_ASSEMBLY, ]) ->getQuery() diff --git a/src/Controller/Api/AdherentController.php b/src/Controller/Api/AdherentController.php index 1acde48637c..1c2f8263ac3 100644 --- a/src/Controller/Api/AdherentController.php +++ b/src/Controller/Api/AdherentController.php @@ -16,7 +16,7 @@ class AdherentController extends AbstractController { - #[IsGranted('ROLE_ADHERENT')] + #[IsGranted('ROLE_USER')] #[Route(path: '/adherents/me/anonymize', name: 'api_adherent_anonymize_me', methods: ['PUT'])] public function anonymizeAction( Request $request, diff --git a/src/Controller/Api/AdherentMessage/GetAdherentMessageStatusController.php b/src/Controller/Api/AdherentMessage/GetAdherentMessageStatusController.php index 5caff4eea49..72783f78150 100644 --- a/src/Controller/Api/AdherentMessage/GetAdherentMessageStatusController.php +++ b/src/Controller/Api/AdherentMessage/GetAdherentMessageStatusController.php @@ -10,7 +10,7 @@ use Symfony\Component\Serializer\SerializerInterface; #[Route(path: '/adherent_messages/{uuid}', name: 'app_api_get_adherent_message_status', methods: ['GET'])] -#[Security("is_granted('ROLE_ADHERENT') and (message.getAuthor() == user or user.hasDelegatedFromUser(message.getAuthor(), 'messages'))")] +#[Security("is_granted('ROLE_USER') and (message.getAuthor() == user or user.hasDelegatedFromUser(message.getAuthor(), 'messages'))")] class GetAdherentMessageStatusController extends AbstractController { public function __invoke(AbstractAdherentMessage $message, SerializerInterface $serializer): Response diff --git a/src/Controller/Api/ProfileController.php b/src/Controller/Api/ProfileController.php index 3c768df5f96..ff760594531 100644 --- a/src/Controller/Api/ProfileController.php +++ b/src/Controller/Api/ProfileController.php @@ -161,12 +161,7 @@ public function update( AbstractNormalizer::GROUPS => $groups, ]); - $validationGroups = ['api_put_validation']; - if ($adherent->isAdherent()) { - $validationGroups[] = 'Default'; - } - - $violations = $validator->validate($adherentProfile, null, $validationGroups); + $violations = $validator->validate($adherentProfile, null, ['Default', 'api_put_validation']); if (0 === $violations->count()) { $handler->update($adherent, $adherentProfile); @@ -293,7 +288,8 @@ public function terminateMembershipAction( AbstractNormalizer::GROUPS => ['unregister'], ]); - $validationGroups = [$user->isAdherent() ? 'unregister_adherent' : 'unregister_user']; + /** @var Adherent $user */ + $validationGroups = [$user->isRenaissanceAdherent() ? 'unregister_adherent' : 'unregister_user']; if ($user->getAuthAppVersion() >= 5110) { $validationGroups[] = 'unregister'; diff --git a/src/Controller/Api/Statistics/AbstractStatisticsController.php b/src/Controller/Api/Statistics/AbstractStatisticsController.php deleted file mode 100644 index 69f78e5b1a2..00000000000 --- a/src/Controller/Api/Statistics/AbstractStatisticsController.php +++ /dev/null @@ -1,13 +0,0 @@ -countByGender(); - - return new JsonResponse($this->aggregateCount($count)); - } - - private function aggregateCount(array $count): array - { - array_walk($count, function (&$item) { - $item = (int) $item['count']; - }); - - $count['total'] = array_sum($count); - - return $count; - } -} diff --git a/src/Controller/Api/UserController.php b/src/Controller/Api/UserController.php index 705836f0794..4f1d7841f4d 100644 --- a/src/Controller/Api/UserController.php +++ b/src/Controller/Api/UserController.php @@ -54,7 +54,7 @@ public function oauthShowMe(SerializerInterface $serializer) ); } - #[IsGranted('ROLE_ADHERENT')] + #[IsGranted('ROLE_USER')] public function showMe(SerializerInterface $serializer): JsonResponse { /* @var Adherent $user */ diff --git a/src/Controller/EnMarche/AdherentProfile/FunnelController.php b/src/Controller/EnMarche/AdherentProfile/FunnelController.php index baf652e27bb..71cae385015 100644 --- a/src/Controller/EnMarche/AdherentProfile/FunnelController.php +++ b/src/Controller/EnMarche/AdherentProfile/FunnelController.php @@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; -#[IsGranted('ROLE_ADHERENT')] +#[IsGranted('ROLE_USER')] class FunnelController extends AbstractController { #[Route(path: '/funnel/general', name: 'app_funnel_general', methods: ['GET', 'POST'])] diff --git a/src/Controller/EnMarche/CommitteeController.php b/src/Controller/EnMarche/CommitteeController.php index c2013dd4c3a..84dda68ff05 100644 --- a/src/Controller/EnMarche/CommitteeController.php +++ b/src/Controller/EnMarche/CommitteeController.php @@ -102,7 +102,6 @@ public function timelineAction(Request $request, Committee $committee): Response return $this->render('committee/timeline/_feed.html.twig', [ 'committee' => $committee, 'committee_timeline' => $timeline, - 'has_role_adherent' => $this->getUser() instanceof Adherent && $this->getUser()->isAdherent(), 'has_role_user' => $this->isGranted('ROLE_USER'), ]); } diff --git a/src/Controller/EnMarche/EventController.php b/src/Controller/EnMarche/EventController.php index 7f482e17b96..7956d8df38c 100644 --- a/src/Controller/EnMarche/EventController.php +++ b/src/Controller/EnMarche/EventController.php @@ -66,7 +66,7 @@ public function exportIcalAction(BaseEvent $event, SerializerInterface $serializ } #[Entity('event', expr: 'repository.findOneActiveBySlug(slug)')] - #[IsGranted('ROLE_ADHERENT')] + #[IsGranted('ROLE_USER')] #[Route(path: '/inscription-adherent', name: '_attend_adherent', methods: ['GET'])] public function attendAdherentAction( BaseEvent $event, diff --git a/src/Controller/EnMarche/InvitationController.php b/src/Controller/EnMarche/InvitationController.php index 1505bed89b2..bdd0841695e 100644 --- a/src/Controller/EnMarche/InvitationController.php +++ b/src/Controller/EnMarche/InvitationController.php @@ -43,7 +43,7 @@ public function inviteAction(Request $request, InvitationRequestHandler $handler ]); } - #[IsGranted('ROLE_ADHERENT')] + #[IsGranted('ROLE_USER')] #[Route(path: '/espace-depute/invitation', name: 'app_deputy_adherent_invitation', methods: ['GET', 'POST'], defaults: ['type' => 'deputy'])] #[Route(path: '/espace-comite/{slug}/invitation', name: 'app_supervisor_adherent_invitation', methods: ['GET', 'POST'], defaults: ['type' => 'supervisor'])] #[Route(path: '/espace-candidat-legislative/invitation', name: 'app_legislative_candidate_adherent_invitation', methods: ['GET', 'POST'], defaults: ['type' => 'legislative_candidate'])] diff --git a/src/Controller/EnMarche/MyVoteController.php b/src/Controller/EnMarche/MyVoteController.php deleted file mode 100644 index 17332026079..00000000000 --- a/src/Controller/EnMarche/MyVoteController.php +++ /dev/null @@ -1,23 +0,0 @@ -disableInProduction(); - - return $this->render('adherent/my_vote.html.twig'); - } -} diff --git a/src/Controller/EnMarche/UserController.php b/src/Controller/EnMarche/UserController.php index 9715f423821..0914d146880 100644 --- a/src/Controller/EnMarche/UserController.php +++ b/src/Controller/EnMarche/UserController.php @@ -122,8 +122,9 @@ public function terminateMembershipAction( } $unregistrationCommand = new UnregistrationCommand(); - $viewFolder = $user->isUser() ? 'user' : 'adherent'; - $reasons = $user->isUser() ? Unregistration::REASONS_LIST_USER : Unregistration::REASONS_LIST_ADHERENT; + /** @var Adherent $user */ + $viewFolder = $user->isRenaissanceSympathizer() ? 'user' : 'adherent'; + $reasons = $user->isRenaissanceSympathizer() ? Unregistration::REASONS_LIST_USER : Unregistration::REASONS_LIST_ADHERENT; $form = $this->createForm(UnregistrationType::class, $unregistrationCommand, [ 'csrf_token_id' => self::UNREGISTER_TOKEN, @@ -134,7 +135,7 @@ public function terminateMembershipAction( $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $handler->terminateMembership($user, $unregistrationCommand, $user->isAdherent()); + $handler->terminateMembership($user, $unregistrationCommand, $user->isRenaissanceAdherent()); $security->logout(false); return $this->render( diff --git a/src/Controller/Renaissance/Adherent/NotificationPreferencesController.php b/src/Controller/Renaissance/Adherent/NotificationPreferencesController.php index d2872376f3d..b29dfdddb0e 100644 --- a/src/Controller/Renaissance/Adherent/NotificationPreferencesController.php +++ b/src/Controller/Renaissance/Adherent/NotificationPreferencesController.php @@ -26,7 +26,7 @@ public function __invoke( $form = $this ->createForm(AdherentEmailSubscriptionType::class, $adherent, [ - 'is_adherent' => $adherent->isAdherent(), + 'is_adherent' => $adherent->isRenaissanceAdherent(), 'validation_groups' => 'subscriptions_update', ]) ->handleRequest($request) diff --git a/src/Entity/Adherent.php b/src/Entity/Adherent.php index e8e8d820147..c199ecabeb6 100644 --- a/src/Entity/Adherent.php +++ b/src/Entity/Adherent.php @@ -243,10 +243,6 @@ class Adherent implements UserInterface, UserEntityInterface, GeoPointInterface, #[ORM\OneToMany(mappedBy: 'author', targetEntity: CommitteeFeedItem::class, cascade: ['remove'])] private $committeeFeedItems; - #[Groups(['profile_read'])] - #[ORM\Column(type: 'boolean', options: ['default' => false])] - private $adherent = false; - /** * @var InMemoryOAuthUser|null */ @@ -657,10 +653,6 @@ public function getRoles(): array { $roles = ['ROLE_USER']; - if ($this->isAdherent()) { - $roles[] = 'ROLE_ADHERENT'; - } - if ($this->isDeputy()) { $roles[] = 'ROLE_DEPUTY'; } @@ -1359,21 +1351,6 @@ public function isDelegatedPresidentDepartmentalAssembly(): bool return \count($this->getReceivedDelegatedAccessOfType(ScopeEnum::PRESIDENT_DEPARTMENTAL_ASSEMBLY)) > 0; } - public function isAdherent(): bool - { - return $this->adherent; - } - - public function isUser(): bool - { - return !$this->isAdherent(); - } - - public function join(): void - { - $this->adherent = true; - } - public function getOAuthUser(): InMemoryOAuthUser { if (!$this->oAuthUser) { diff --git a/src/Entity/Jecoute/JemarcheDataSurvey.php b/src/Entity/Jecoute/JemarcheDataSurvey.php index 9381592889b..767965f0acb 100644 --- a/src/Entity/Jecoute/JemarcheDataSurvey.php +++ b/src/Entity/Jecoute/JemarcheDataSurvey.php @@ -28,11 +28,11 @@ requirements: ['uuid' => '%pattern_uuid%'], controller: JemarcheDataSurveyReplyController::class, normalizationContext: ['groups' => ['data_survey_read']], - security: '(is_granted(\'ROLE_ADHERENT\') or is_granted(\'ROLE_OAUTH_DEVICE\')) and (is_granted(\'ROLE_OAUTH_SCOPE_JECOUTE_SURVEYS\') or is_granted(\'ROLE_OAUTH_SCOPE_JEMARCHE_APP\'))' + security: '(is_granted(\'ROLE_USER\') or is_granted(\'ROLE_OAUTH_DEVICE\')) and (is_granted(\'ROLE_OAUTH_SCOPE_JECOUTE_SURVEYS\') or is_granted(\'ROLE_OAUTH_SCOPE_JEMARCHE_APP\'))' ), new Post( uriTemplate: '/v3/jemarche_data_surveys', - security: '(is_granted(\'ROLE_ADHERENT\') or is_granted(\'ROLE_OAUTH_DEVICE\')) and (is_granted(\'ROLE_OAUTH_SCOPE_JECOUTE_SURVEYS\') or is_granted(\'ROLE_OAUTH_SCOPE_JEMARCHE_APP\'))' + security: '(is_granted(\'ROLE_USER\') or is_granted(\'ROLE_OAUTH_DEVICE\')) and (is_granted(\'ROLE_OAUTH_SCOPE_JECOUTE_SURVEYS\') or is_granted(\'ROLE_OAUTH_SCOPE_JEMARCHE_APP\'))' ), new GetCollection( uriTemplate: '/v3/jemarche_data_surveys/kpi', diff --git a/src/Membership/AdherentFactory.php b/src/Membership/AdherentFactory.php index 31538597500..910ee936a3e 100644 --- a/src/Membership/AdherentFactory.php +++ b/src/Membership/AdherentFactory.php @@ -113,7 +113,6 @@ public function createFromBesoinDEuropeMembershipRequest(InscriptionRequest $ins $adherent->tags = [TagEnum::SYMPATHISANT_ENSEMBLE2024]; $adherent->setPapUserRole(true); - $adherent->join(); $adherent->setV2(true); $adherent->finishAdhesionStep(AdhesionStepEnum::MAIN_INFORMATION); $adherent->setSource(MembershipSourceEnum::LEGISLATIVE); @@ -154,7 +153,7 @@ public function createFromArray(array $data): Adherent $phone = PhoneNumberUtils::create($data['phone']); } - $adherent = Adherent::create( + return Adherent::create( isset($data['uuid']) ? Uuid::fromString($data['uuid']) : Adherent::createUuid($data['email']), $data['email'], $this->hashPassword($data['password']), @@ -174,12 +173,6 @@ public function createFromArray(array $data): Adherent $data['custom_gender'] ?? null, AdhesionStepEnum::all($data['is_adherent'] ?? false), ); - - if (!isset($data['is_adherent']) || $data['is_adherent']) { - $adherent->join(); - } - - return $adherent; } /** diff --git a/src/Renaissance/Membership/Admin/AdherentCreateCommandHandler.php b/src/Renaissance/Membership/Admin/AdherentCreateCommandHandler.php index 9e3f617b56c..13304322999 100644 --- a/src/Renaissance/Membership/Admin/AdherentCreateCommandHandler.php +++ b/src/Renaissance/Membership/Admin/AdherentCreateCommandHandler.php @@ -49,7 +49,6 @@ public function handle( } $adherent->finishAdhesionStep(AdhesionStepEnum::MAIN_INFORMATION); - $adherent->join(); $adherent->setPapUserRole(true); $this->entityManager->persist($adherent); diff --git a/src/Repository/AdherentRepository.php b/src/Repository/AdherentRepository.php index 96bd96a7922..acbd9488741 100644 --- a/src/Repository/AdherentRepository.php +++ b/src/Repository/AdherentRepository.php @@ -73,7 +73,8 @@ public function countAdherents(): int return (int) $this ->createQueryBuilder('a') ->select('COUNT(a)') - ->andWhere('a.adherent = 1') + ->andWhere('a.tags LIKE :adherent_tag') + ->setParameter('adherent_tag', TagEnum::ADHERENT.'%') ->getQuery() ->getSingleScalarResult() ; @@ -251,19 +252,6 @@ public function findAdherentsUuidByEmailAddress(string $emailAddress): array }, array_column($query->getArrayResult(), 'uuid')); } - public function countByGender(): array - { - return $this->createQueryBuilder('a', 'a.gender') - ->select('a.gender, COUNT(a) AS count') - ->where('a.adherent = 1') - ->andWhere('a.status = :status') - ->setParameter('status', Adherent::ENABLED) - ->groupBy('a.gender') - ->getQuery() - ->getArrayResult() - ; - } - public function refresh(Adherent $adherent): void { $this->getEntityManager()->refresh($adherent); @@ -516,7 +504,7 @@ public function createQueryBuilderForAudience(AudienceInterface $audience): Quer ->andWhere('adherent.status = :adherent_status') ->setParameter('adherent_status', Adherent::ENABLED) ->andWhere((new Orx()) - ->add('adherent.source IS NULL AND adherent.adherent = true') + ->add('adherent.source IS NULL') ->add('adherent.source = :source_jme') ->add('adherent.source = :source_renaissance') ) @@ -595,7 +583,6 @@ public function createQueryBuilderForAudience(AudienceInterface $audience): Quer function (QueryBuilder $zoneQueryBuilder, string $entityClassAlias) { $zoneQueryBuilder ->andWhere(\sprintf('%s.status = :adherent_status', $entityClassAlias)) - ->andWhere(\sprintf('%s.adherent = true', $entityClassAlias)) ->andWhere((new Orx()) ->add(\sprintf('%s.source IS NULL', $entityClassAlias)) ->add(\sprintf('%s.source = :source_jme', $entityClassAlias)) @@ -1106,7 +1093,6 @@ public function associateWithVoterList(Designation $designation, VotersList $lis adherent.status = :status AND adherent.registered_at < :since_date AND adherent.certified_at IS NOT NUll - AND adherent.adherent = 1 AND adherent.source IS NULL ON DUPLICATE KEY UPDATE is_poll_voter = 1 SQL; @@ -1125,7 +1111,6 @@ public function associateWithVoterList(Designation $designation, VotersList $lis AND adherent.status = :status AND adherent.registered_at < :since_date AND adherent.certified_at IS NOT NUll - AND adherent.adherent = 1 AND adherent.source IS NULL SQL; diff --git a/src/Security/Voter/AdherentUnregistrationVoter.php b/src/Security/Voter/AdherentUnregistrationVoter.php index b2a70617b7c..64be75c9960 100644 --- a/src/Security/Voter/AdherentUnregistrationVoter.php +++ b/src/Security/Voter/AdherentUnregistrationVoter.php @@ -22,10 +22,6 @@ protected function voteOnAttribute(string $attribute, $subject, TokenInterface $ return false; } - if ($subject->isUser()) { - return true; - } - return !$subject->isPresidentDepartmentalAssembly() && !$subject->isAnimator() && !$subject->isDeputy() diff --git a/src/Subscription/SubscriptionHandler.php b/src/Subscription/SubscriptionHandler.php index 428cb736571..bdc3fce2610 100644 --- a/src/Subscription/SubscriptionHandler.php +++ b/src/Subscription/SubscriptionHandler.php @@ -81,11 +81,7 @@ public function handleUpdateSubscription(Adherent $adherent, array $newSubscript private function getEmailDefaultTypes(Adherent $adherent): array { - if ($adherent->isAdherent()) { - $types = SubscriptionTypeEnum::DEFAULT_EMAIL_TYPES; - } else { - $types = SubscriptionTypeEnum::USER_TYPES; - } + $types = SubscriptionTypeEnum::DEFAULT_EMAIL_TYPES; if ($adherent->getAge() && $adherent->getAge() < 35) { $types[] = SubscriptionTypeEnum::JAM_EMAIL; diff --git a/src/Twig/AdherentExtension.php b/src/Twig/AdherentExtension.php index 98720ecfbfd..cd18e643f32 100644 --- a/src/Twig/AdherentExtension.php +++ b/src/Twig/AdherentExtension.php @@ -10,13 +10,10 @@ class AdherentExtension extends AbstractExtension public function getFunctions(): array { return [ - new TwigFunction('member_interest_label', [AdherentRuntime::class, 'getMemberInterestLabel']), - new TwigFunction('get_user_level_label', [AdherentRuntime::class, 'getUserLevelLabel']), new TwigFunction('get_adherent_role_labels', [AdherentRuntime::class, 'getAdherentRoleLabels']), new TwigFunction('get_elected_representative', [AdherentRuntime::class, 'getElectedRepresentative']), new TwigFunction('has_active_parliamentary_mandate', [AdherentRuntime::class, 'hasActiveParliamentaryMandate']), new TwigFunction('get_session_modal_context', [AdherentRuntime::class, 'getSessionModalContext']), - new TwigFunction('get_name_by_uuid', [AdherentRuntime::class, 'getNameByUuid']), new TwigFunction('translate_tag', [AdherentRuntime::class, 'translateTag']), new TwigFunction('count_contribution', [AdherentRuntime::class, 'countContribution']), new TwigFunction('get_adherent_by_uuid', [AdherentRuntime::class, 'getAdherentByUuid']), diff --git a/src/Twig/AdherentRuntime.php b/src/Twig/AdherentRuntime.php index cb46a7c0158..4cccf65d1a0 100644 --- a/src/Twig/AdherentRuntime.php +++ b/src/Twig/AdherentRuntime.php @@ -21,46 +21,14 @@ public function __construct( private readonly AdherentRepository $adherentRepository, private readonly DonationRepository $donationRepository, private readonly TagTranslator $tagTranslator, - private readonly array $adherentInterests, ) { } - public function getMemberInterestLabel(string $interest) - { - if (!isset($this->adherentInterests[$interest])) { - return ''; - } - - return $this->adherentInterests[$interest]; - } - public function translateTag(string $tag, bool $fullTag = true): string { return $this->tagTranslator->trans($tag, $fullTag); } - public function getUserLevelLabel(Adherent $adherent): string - { - if (!$adherent->isAdherent()) { - return 'Non-adhérent(e)'; - } - - if ($adherent->isDeputy()) { - return $adherent->isFemale() ? 'Députée 🏛' : 'Député 🏛'; - } - - if ($adherent->isSupervisor()) { - return $adherent->isFemale() ? 'Animatrice 🏅' : 'Animateur 🏅'; - } - - if ($adherent->isHost()) { - return $adherent->isFemale() ? 'Co-animatrice 🏅' : 'Co-animateur 🏅'; - } - - // It means the user is an adherent - return $adherent->isFemale() ? 'Adhérente 😍' : 'Adhérent 😍'; - } - public function getAdherentRoleLabels(Adherent $adherent): array { $labels = []; @@ -101,13 +69,6 @@ public function getElectedRepresentative(Adherent $adherent): ?ElectedRepresenta return $this->electedRepresentativeRepository->findOneBy(['adherent' => $adherent]); } - public function getNameByUuid(string $uuid): string - { - $adherent = $this->adherentRepository->findNameByUuid($uuid); - - return \count($adherent) > 0 ? $adherent[0]['firstName'].' '.$adherent[0]['lastName'] : ''; - } - public function hasActiveParliamentaryMandate(Adherent $adherent): bool { return $this->electedRepresentativeRepository->hasActiveParliamentaryMandate($adherent); diff --git a/templates/adherent/my_vote.html.twig b/templates/adherent/my_vote.html.twig deleted file mode 100644 index 59dc7706897..00000000000 --- a/templates/adherent/my_vote.html.twig +++ /dev/null @@ -1,70 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block page_title 'Mon vote' %} - -{% block content %} -
-
-
-

Votez sur la réforme des statuts

-

- Le scrutin sur la réforme des statuts est désormais ouvert ! Pour voter, il vous suffit de cliquer sur le bouton ci-dessous : -

-
-
- Je vote -
-
-

Pourquoi ?

-

Cette réforme, c'est l'acte II de La République En Marche. Tout en gardant ce qui fait notre identité, elle doit nous permettre de renforcer notre ancrage territorial et de préparer le Mouvement à l’arrivée de milliers d’élues locales/élus locaux à la suite des prochaines échéances électorales.

-

Cette réforme est le fruit d’un large travail de co-construction : plus de 4 000 contributions déposées par nos adhérents sur l’Atelier des idées, plus de 200 réunions physiques organisées par nos comités à travers tout le pays et des dizaines d’auditions d'experts.

- -

Ce projet de nouveaux statuts repose sur 5 piliers :

- -

1. Voter et mieux voter

-

2. Décentraliser davantage

-

3. Assurer une meilleure représentativité

-

4. Garantir la parité à tous les niveaux

-

5. Rester fidèles à nos marqueurs

-
- -

-

Retrouvez ci-dessous le schéma récapitulatif de la réforme :

- -
- - - -
-

- -

Consultez également l’intégralité du projet de statuts :

-
- -

- -

Quand ?

-

Le vote se déroulera du lundi 25 novembre 2019 à 18h00 au lundi 16 décembre 2019 à midi (heure de Paris).

- -

Comment ?

- -

Cliquez sur le bouton JE VOTE ci-dessous. Saisissez ensuite vos codes identifiants de vote personnels que vous avez reçus par email le 25 novembre 2019 (si vous êtes votant).

- -

Qui peut voter ?

-

Tous les adhérents ayant adhéré depuis plus de 6 mois peuvent participer au vote.
- Cliquez ici pour consulter le règlement intérieur relatif au vote.

- -

D’autres questions ? Consulter ici la FAQ dédiée à la procédure de vote.

-
-
- Je vote -
- -
-
-
-{% endblock %} diff --git a/templates/adherent_profile/_layout.html.twig b/templates/adherent_profile/_layout.html.twig index bccf04fa733..ee50537c9ae 100644 --- a/templates/adherent_profile/_layout.html.twig +++ b/templates/adherent_profile/_layout.html.twig @@ -28,7 +28,7 @@ {% endif %}
- {% if has_role_adherent and app.user.activatedAt %} + {% if has_role_user and app.user.activatedAt %} Adhérent{{ app.user.female ? 'e' }} depuis le
{{ app.user.registeredAt|format_datetime('none', 'none', 'd MMMM yyyy à HH:mm') }} {% else %} Non adhérent{{ app.user.female ? 'e' }}. diff --git a/templates/base.html.twig b/templates/base.html.twig index cbbb79e83dd..02c9525e9c6 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -6,7 +6,6 @@ {% set default_sharer_height = 840 %} {% set has_role_user = is_granted('ROLE_USER') %} -{% set has_role_adherent = is_granted('ROLE_ADHERENT') %} {% set has_role_admin = is_granted('ROLE_ADMIN_DASHBOARD') %} {% set is_certified = is_granted(constant('App\\Adherent\\Certification\\CertificationPermissions::CERTIFIED')) %} {% endapply %} diff --git a/templates/committee/_sidebar.html.twig b/templates/committee/_sidebar.html.twig index 14d99628f54..db755e653ef 100644 --- a/templates/committee/_sidebar.html.twig +++ b/templates/committee/_sidebar.html.twig @@ -3,7 +3,7 @@
Vous êtes membre de ce comité depuis le {{ membership.subscriptionDate|format_datetime('none', 'none', 'd MMMM yyyy à HH:mm') }}
{% endif %} - {% if has_role_adherent and committee.hasActiveElection and is_granted('ABLE_TO_CANDIDATE_IN_COMMITTEE', committee) %} + {% if has_role_user and committee.hasActiveElection and is_granted('ABLE_TO_CANDIDATE_IN_COMMITTEE', committee) %} {% set committee_election = committee.committeeElection %} {# If the vote was started, hide box if 0 candidates #} @@ -48,7 +48,7 @@ {{ host.initials }}
-
{{ has_role_adherent ? host.fullName : host.partialName }}
+
{{ has_role_user ? host.fullName : host.partialName }}
{% if host.female %} {{ host.isSupervisorOf(committee, false) @@ -87,7 +87,7 @@ {{ adherent.initials }}
-
{{ has_role_adherent ? adherent.fullName : adherent.partialName }}
+
{{ has_role_user ? adherent.fullName : adherent.partialName }}
{{ adherent.isFemale ? 'Adhérente désignée' : 'Adhérent désigné' }}
diff --git a/templates/committee/show.html.twig b/templates/committee/show.html.twig index 82220c592cf..be54fdf5095 100644 --- a/templates/committee/show.html.twig +++ b/templates/committee/show.html.twig @@ -3,7 +3,7 @@ {% block page_title %}{{ committee.name }} - {{ committee.cityName }}{% endblock %} {% block canonical_url url('app_committee_show', {slug: committee.slug}) %} -{% set membership = is_granted('ROLE_ADHERENT') ? app.user.getMembershipFor(committee) : null %} +{% set membership = is_granted('ROLE_USER') ? app.user.getMembershipFor(committee) : null %} {% block json_ld %}