diff --git a/features/api/designations.feature b/features/api/designations.feature index 25d506b35f..5e909bfd7d 100644 --- a/features/api/designations.feature +++ b/features/api/designations.feature @@ -96,9 +96,11 @@ Feature: "description": "lorem ipsum...", "target": [], "fully_editable": true, + "created_at": "@string@.isDateTime()", "questions": [], "election_entity_identifier": "8c4b48ec-9290-47ae-a5db-d1cf2723e8b3", - "uuid": "@uuid@" + "uuid": "@uuid@", + "is_canceled": false } """ @@ -125,7 +127,9 @@ Feature: "questions": [], "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit", "election_entity_identifier": "5e00c264-1d4b-43b8-862e-29edc38389b3", - "uuid": "7fb0693e-1dad-44c6-984b-19e99603ea2c" + "uuid": "7fb0693e-1dad-44c6-984b-19e99603ea2c", + "is_canceled": false, + "created_at": "@string@.isDateTime()" } """ @@ -162,7 +166,9 @@ Feature: "questions": [], "description": "lorem ipsum...", "election_entity_identifier": "8c4b48ec-9290-47ae-a5db-d1cf2723e8b3", - "uuid": "6c7ca0c7-d656-47c3-a345-170fb43ffd1a" + "uuid": "6c7ca0c7-d656-47c3-a345-170fb43ffd1a", + "is_canceled": false, + "created_at": "@string@.isDateTime()" } """ @@ -313,7 +319,7 @@ Feature: Scenario Outline: As a grand user with local scope, I can cancel an election Given I am logged with "" via OAuth client "JeMengage Web" with scope "jemengage_admin" When I send a "PUT" request to "/api/v3/designations/7fb0693e-1dad-44c6-984b-19e99603ea2c/cancel?scope=" - Then the response status code should be 204 + Then the response status code should be 409 When I send a "GET" request to "/api/v3/designations/7fb0693e-1dad-44c6-984b-19e99603ea2c?scope=" Then the response status code should be 200 And the response should be in JSON @@ -330,7 +336,9 @@ Feature: "questions": [], "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit", "election_entity_identifier": "5e00c264-1d4b-43b8-862e-29edc38389b3", - "uuid": "7fb0693e-1dad-44c6-984b-19e99603ea2c" + "uuid": "7fb0693e-1dad-44c6-984b-19e99603ea2c", + "is_canceled": false, + "created_at": "@string@.isDateTime()" } """ diff --git a/src/Controller/Api/VotingPlatform/CancelElectionController.php b/src/Controller/Api/VotingPlatform/CancelElectionController.php index d76e528ffa..4c8ec619c3 100644 --- a/src/Controller/Api/VotingPlatform/CancelElectionController.php +++ b/src/Controller/Api/VotingPlatform/CancelElectionController.php @@ -16,6 +16,13 @@ public function __invoke( EntityManagerInterface $entityManager, ElectionRepository $electionRepository, ): Response { + if (!$designation->isFullyEditable()) { + return $this->json([ + 'status' => 'error', + 'message' => 'Consultation is not editable', + ], Response::HTTP_CONFLICT); + } + foreach ($electionRepository->findAllForDesignation($designation) as $election) { $election->cancel(ElectionCancelReasonEnum::Manual); } diff --git a/src/Entity/EntityTimestampableTrait.php b/src/Entity/EntityTimestampableTrait.php index 1b099dcf26..f50f22603c 100644 --- a/src/Entity/EntityTimestampableTrait.php +++ b/src/Entity/EntityTimestampableTrait.php @@ -12,7 +12,7 @@ trait EntityTimestampableTrait * @var \DateTimeInterface */ #[Gedmo\Timestampable(on: 'create')] - #[Groups(['jecoute_news_read', 'jecoute_news_read_dc', 'email_template_read', 'email_template_list_read', 'riposte_list_read', 'riposte_read', 'phoning_campaign_read', 'message_read_list', 'pap_building_history', 'pap_campaign_history_read_list', 'pap_campaign_replies_list', 'event_read', 'event_list_read', 'survey_list_dc', 'committee:list', 'document_read', 'national_event_inscription:webhook', 'procuration_request_read', 'procuration_request_list', 'procuration_proxy_list', 'procuration_matched_proxy', 'action_read', 'action_read_list', 'adherent_elect_read', 'tax_receipt:list', 'designation_list'])] + #[Groups(['jecoute_news_read', 'jecoute_news_read_dc', 'email_template_read', 'email_template_list_read', 'riposte_list_read', 'riposte_read', 'phoning_campaign_read', 'message_read_list', 'pap_building_history', 'pap_campaign_history_read_list', 'pap_campaign_replies_list', 'event_read', 'event_list_read', 'survey_list_dc', 'committee:list', 'document_read', 'national_event_inscription:webhook', 'procuration_request_read', 'procuration_request_list', 'procuration_proxy_list', 'procuration_matched_proxy', 'action_read', 'action_read_list', 'adherent_elect_read', 'tax_receipt:list', 'designation_list', 'designation_read'])] #[ORM\Column(type: 'datetime')] protected $createdAt; diff --git a/src/Entity/VotingPlatform/Designation/Designation.php b/src/Entity/VotingPlatform/Designation/Designation.php index 27493f30c8..d68505b94b 100644 --- a/src/Entity/VotingPlatform/Designation/Designation.php +++ b/src/Entity/VotingPlatform/Designation/Designation.php @@ -262,6 +262,7 @@ class Designation implements EntityAdministratorBlameableInterface, EntityAdhere #[ORM\Column(type: 'uuid', nullable: true)] private ?UuidInterface $electionEntityIdentifier = null; + #[Groups(['designation_read', 'designation_list'])] #[ORM\Column(type: 'boolean', options: ['default' => false])] private bool $isCanceled = false; @@ -878,4 +879,11 @@ public function isLimitedResultsView(): bool DesignationTypeEnum::COMMITTEE_SUPERVISOR, ], true); } + + public function getTargetYear(): ?int + { + $year = $this->target ? substr($this->target[0], -4) : null; + + return $year > 2022 ? $year : date('Y') - 1; + } } diff --git a/src/Security/Voter/VotingPlatformAbleToVoteVoter.php b/src/Security/Voter/VotingPlatformAbleToVoteVoter.php index 80eda71e21..ca5445822c 100644 --- a/src/Security/Voter/VotingPlatformAbleToVoteVoter.php +++ b/src/Security/Voter/VotingPlatformAbleToVoteVoter.php @@ -2,6 +2,7 @@ namespace App\Security\Voter; +use App\Adherent\Tag\TagEnum; use App\Entity\Adherent; use App\Entity\Geo\Zone; use App\Entity\VotingPlatform\Election; @@ -40,7 +41,14 @@ protected function doVoteOnAttribute(string $attribute, Adherent $adherent, $sub if ($designation->isConsultationType()) { if ($designation->target) { - if (!array_sum(array_map([$adherent, 'hasTag'], $designation->target))) { + $foundTargetTag = false; + foreach (range($designation->getTargetYear(), date('Y')) as $year) { + if ($adherent->hasTag(TagEnum::getAdherentYearTag($year))) { + $foundTargetTag = true; + break; + } + } + if (!$foundTargetTag) { return false; } } elseif (!$adherent->hasActiveMembership()) { diff --git a/templates/voting_platform/_layout_consultation.html.twig b/templates/voting_platform/_layout_consultation.html.twig index 2d6ce3b667..4f711fd5d1 100644 --- a/templates/voting_platform/_layout_consultation.html.twig +++ b/templates/voting_platform/_layout_consultation.html.twig @@ -29,9 +29,8 @@ {% block vote_finish_action_block %} {% endblock %} diff --git a/templates/voting_platform/finish.html.twig b/templates/voting_platform/finish.html.twig index 666bf51354..86fe2be2fc 100644 --- a/templates/voting_platform/finish.html.twig +++ b/templates/voting_platform/finish.html.twig @@ -32,13 +32,12 @@ +

{% if designation.isExecutiveOfficeType() or designation.isLocalElectionTypes() or designation.isCommitteeSupervisorType() %} Félicitations, votre bulletin est dans l'urne ! {% elseif designation.isPollType() %} Félicitations, votre vote est bien enregistré ! - {% elseif designation.isConsultationType() %} - Félicitations, votre participation a été enregistrée ! {% else %} Félicitations, vos bulletins sont dans l'urne ! {% endif %} @@ -51,6 +50,31 @@ {% block voting_platform_content %}
+

+ {% if designation.isExecutiveOfficeType() or designation.isPollType() or designation.isCommitteeSupervisorType() %} + Votre bulletin a été anonymisé.

+ Le numéro ci-dessous, connu de vous seul, est l'unique moyen de tracer votre + bulletin de votre choix au dépouillement. Retrouvez-le dans le détail des résultats. + {% elseif designation.isLocalElectionTypes() %} + Votre bulletin a été anonymisé.

+ Le numéro ci-dessous, connu de vous seul, est l'unique moyen de tracer votre bulletin. + {% else %} + Vos bulletins ont été anonymisés.

+ Le numéro ci-dessous, connu de vous seul, est l'unique moyen de tracer vos + bulletins de votre choix au dépouillement. Retrouvez-le dans le détail des résultats. + {% endif %} +

+ +
+
{{ voter_key }}
+
+ +

+ Attention. Une fois cette page fermée, vous ne pourrez retrouver le numéro anonyme de vos bulletins que dans le mail + de confirmation que vous venez de recevoir. Aucun lien entre vous et ce numéro n'étant enregistré, nous ne serons pas + en mesure de vous le redonner. +

+ {{ block('vote_finish_action_block') }}
{% endblock %} @@ -59,8 +83,8 @@ {{ parent() }} {% endblock %}