Skip to content

Commit

Permalink
Remove useless adherent column
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Jan 2, 2025
1 parent 65c09f1 commit 20ba2e7
Show file tree
Hide file tree
Showing 44 changed files with 65 additions and 311 deletions.
4 changes: 2 additions & 2 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand All @@ -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')",
Expand Down
19 changes: 19 additions & 0 deletions migrations/Version20250102173536.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20250102173536 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->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');
}
}
6 changes: 1 addition & 5 deletions src/Adherent/AdherentExtractCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/Adherent/Unregistration/UnregistrationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function createFromUnregistrationCommandAndAdherent(
$command->getComment(),
$adherent->getRegisteredAt(),
$adherent->getPostAddress()->getPostalCode(),
$adherent->isAdherent(),
$adherent->isRenaissanceAdherent(),
$adherent->isRenaissanceUser(),
$command->getExcludedBy()
);
Expand All @@ -33,7 +33,7 @@ public static function createFromAdherent(Adherent $adherent, ?string $comment =
$comment,
$adherent->getRegisteredAt(),
$adherent->getPostAddress()->getPostalCode(),
$adherent->isAdherent(),
$adherent->isRenaissanceAdherent(),
$adherent->isRenaissanceUser(),
);
}
Expand Down
1 change: 1 addition & 0 deletions src/AdherentProfile/AdherentProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/Adhesion/Handler/CreateAccountCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function __invoke(CreateAccountCommand $command): CreateAdherentResult
3 => MembershipTypeEnum::OTHER,
};

$currentUser->join();
$currentUser->setV2(true);
$currentUser->finishAdhesionStep(AdhesionStepEnum::MAIN_INFORMATION);

Expand Down
1 change: 0 additions & 1 deletion src/Admin/DonationAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/Command/RemindActivatedMembershipCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 2 additions & 3 deletions src/Command/SendAdhesionReportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'),
])
Expand Down
2 changes: 0 additions & 2 deletions src/Command/SendNewMembershipNotificationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Api/AdherentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/Controller/Api/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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';
Expand Down
13 changes: 0 additions & 13 deletions src/Controller/Api/Statistics/AbstractStatisticsController.php

This file was deleted.

33 changes: 0 additions & 33 deletions src/Controller/Api/Statistics/AdherentsController.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Controller/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function oauthShowMe(SerializerInterface $serializer)
);
}

#[IsGranted('ROLE_ADHERENT')]
#[IsGranted('ROLE_USER')]
public function showMe(SerializerInterface $serializer): JsonResponse
{
/* @var Adherent $user */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'])]
Expand Down
1 change: 0 additions & 1 deletion src/Controller/EnMarche/CommitteeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/EnMarche/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/EnMarche/InvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])]
Expand Down
23 changes: 0 additions & 23 deletions src/Controller/EnMarche/MyVoteController.php

This file was deleted.

7 changes: 4 additions & 3 deletions src/Controller/EnMarche/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 0 additions & 23 deletions src/Entity/Adherent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -657,10 +653,6 @@ public function getRoles(): array
{
$roles = ['ROLE_USER'];

if ($this->isAdherent()) {
$roles[] = 'ROLE_ADHERENT';
}

if ($this->isDeputy()) {
$roles[] = 'ROLE_DEPUTY';
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Jecoute/JemarcheDataSurvey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading

0 comments on commit 20ba2e7

Please sign in to comment.