diff --git a/features/api/my_teams.feature b/features/api/my_teams.feature index 89e83ec4c6..57cd97866b 100644 --- a/features/api/my_teams.feature +++ b/features/api/my_teams.feature @@ -340,7 +340,8 @@ Feature: "statutory_message", "procurations", "actions", - "featurebase" + "featurebase", + "circonscriptions" ], "uuid": "e0da56db-c4c6-4aa4-ad8d-7e9505dfdd93" } @@ -425,7 +426,8 @@ Feature: "statutory_message", "procurations", "actions", - "featurebase" + "featurebase", + "circonscriptions" ], "uuid": "@uuid@" } diff --git a/features/api/scopes.feature b/features/api/scopes.feature index 8852c3da4a..bacadca0fa 100644 --- a/features/api/scopes.feature +++ b/features/api/scopes.feature @@ -88,7 +88,8 @@ Feature: "statutory_message", "procurations", "actions", - "featurebase" + "featurebase", + "circonscriptions" ] }, { @@ -222,7 +223,8 @@ Feature: "statutory_message", "procurations", "actions", - "featurebase" + "featurebase", + "circonscriptions" ], "attributes": null, "delegated_access": null @@ -471,7 +473,8 @@ Feature: "statutory_message", "procurations", "actions", - "featurebase" + "featurebase", + "circonscriptions" ], "delegated_access": { "delegator": { @@ -524,7 +527,8 @@ Feature: "statutory_message", "procurations", "actions", - "featurebase" + "featurebase", + "circonscriptions" ], "attributes": { "committees": [{ "name": "Comité des 3 communes", "uuid": "@uuid@" }], diff --git a/src/Entity/AdherentZoneBasedRole.php b/src/Entity/AdherentZoneBasedRole.php index 29f26ddeeb..413a24bc6f 100644 --- a/src/Entity/AdherentZoneBasedRole.php +++ b/src/Entity/AdherentZoneBasedRole.php @@ -2,14 +2,41 @@ namespace App\Entity; +use ApiPlatform\Metadata\ApiResource; +use ApiPlatform\Metadata\Delete; +use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\Post; +use ApiPlatform\Metadata\Put; use App\Adherent\Authorization\ZoneBasedRoleTypeEnum; use App\Collection\ZoneCollection; use App\Entity\Geo\Zone; use App\Scope\ScopeEnum; use Doctrine\ORM\Mapping as ORM; use Ramsey\Uuid\Uuid; +use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; +#[ApiResource( + operations: [ + new GetCollection( + uriTemplate: '/v3/zone_based_role', + ), + new Post( + uriTemplate: '/v3/zone_based_role', + ), + new Put( + uriTemplate: '/v3/zone_based_role/{uuid}', + requirements: ['uuid' => '%pattern_uuid%'] + ), + new Delete( + uriTemplate: '/v3/zone_based_role/{uuid}', + requirements: ['uuid' => '%pattern_uuid%'] + ), + ], + normalizationContext: ['groups' => ['zone_based_role_read']], + denormalizationContext: ['groups' => ['zone_based_role_write']], + security: 'is_granted(\'ROLE_OAUTH_SCOPE_JEMENGAGE_ADMIN\') and is_granted(\'IS_FEATURE_GRANTED\', \'circonscriptions\')' +)] #[ORM\Entity] class AdherentZoneBasedRole { @@ -19,10 +46,12 @@ class AdherentZoneBasedRole #[Assert\Choice(choices: ZoneBasedRoleTypeEnum::ALL)] #[Assert\NotBlank] + #[Groups(['zone_based_role_read', 'zone_based_role_write'])] #[ORM\Column] private ?string $type; #[Assert\NotBlank] + #[Groups(['zone_based_role_read', 'zone_based_role_write'])] #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')] #[ORM\ManyToOne(targetEntity: Adherent::class, inversedBy: 'zoneBasedRoles')] private ?Adherent $adherent = null; diff --git a/src/Entity/EntityIdentityTrait.php b/src/Entity/EntityIdentityTrait.php index 8763fd0273..7b19b2f9cf 100644 --- a/src/Entity/EntityIdentityTrait.php +++ b/src/Entity/EntityIdentityTrait.php @@ -120,6 +120,7 @@ trait EntityIdentityTrait 'user_profile', 'zone_read', 'tax_receipt:list', + 'zone_based_role_read', ])] #[ORM\Column(type: 'uuid', unique: true)] protected $uuid; diff --git a/src/Entity/EntityZoneTrait.php b/src/Entity/EntityZoneTrait.php index e370ce6a59..489534d809 100644 --- a/src/Entity/EntityZoneTrait.php +++ b/src/Entity/EntityZoneTrait.php @@ -13,7 +13,15 @@ trait EntityZoneTrait /** * @var ZoneCollection|Zone[] */ - #[Groups(['phoning_campaign_read', 'phoning_campaign_write', 'read_api', 'managed_users_list', 'managed_user_read'])] + #[Groups([ + 'phoning_campaign_read', + 'phoning_campaign_write', + 'read_api', + 'managed_users_list', + 'managed_user_read', + 'zone_based_role_read', + 'zone_based_role_write', + ])] #[ORM\ManyToMany(targetEntity: Zone::class, cascade: ['persist'])] protected Collection $zones; diff --git a/src/Scope/FeatureEnum.php b/src/Scope/FeatureEnum.php index a658bea06d..074698d9b7 100644 --- a/src/Scope/FeatureEnum.php +++ b/src/Scope/FeatureEnum.php @@ -32,6 +32,7 @@ class FeatureEnum extends Enum public const PROCURATIONS = 'procurations'; public const ACTIONS = 'actions'; public const FEATUREBASE = 'featurebase'; + public const CIRCONSCRIPTIONS = 'circonscriptions'; public const ALL = [ self::DASHBOARD, @@ -60,6 +61,7 @@ class FeatureEnum extends Enum self::PROCURATIONS, self::ACTIONS, self::FEATUREBASE, + self::CIRCONSCRIPTIONS, ]; public const DELEGATED_ACCESSES_BY_DEFAULT = [ diff --git a/translations/messages+intl-icu.fr.yml b/translations/messages+intl-icu.fr.yml index de88335ff3..86ceee7df1 100644 --- a/translations/messages+intl-icu.fr.yml +++ b/translations/messages+intl-icu.fr.yml @@ -1165,6 +1165,7 @@ scope.feature.committee: Comités locaux scope.feature.designation: Désignation scope.feature.actions: Actions scope.feature.featurebase: 🗣 Featurebase ️ +scope.feature.circonscriptions: Gestion des circonscriptions scope.app.data_corner: DataCorner scope.app.jemarche: Je m'engage