Skip to content

Commit

Permalink
[API] allow to get cancelled event (#10169)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed May 1, 2024
1 parent 40f8161 commit b4548f6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
46 changes: 46 additions & 0 deletions features/api/events.feature
Expand Up @@ -813,6 +813,52 @@ Feature:
}
"""

Scenario: As a connected user I can get one cancelled event
Given I am logged with "referent@en-marche-dev.fr" via OAuth client "J'écoute" with scope "jemarche_app"
When I send a "GET" request to "/api/v3/events/4d962b05-68fe-4888-ab6b-53b96bdbe797"
Then the response status code should be 200
And the JSON should be equal to:
"""
{
"uuid": "4d962b05-68fe-4888-ab6b-53b96bdbe797",
"name": "Un événement du référent annulé",
"slug": "@string@-un-evenement-du-referent-annule",
"description": "Description de l'événement du référent annulé",
"time_zone": "Europe/Paris",
"live_url": null,
"visibility": "public",
"created_at": "@string@.isDateTime()",
"begin_at": "@string@.isDateTime()",
"finish_at": "@string@.isDateTime()",
"organizer": {
"uuid": "29461c49-2646-4d89-9c82-50b3f9b586f4",
"first_name": "Referent",
"last_name": "Referent"
},
"participants_count": 0,
"status": "CANCELLED",
"capacity": 50,
"post_address": {
"address": "40 Rue Grande",
"postal_code": "77300",
"city": "77300-77186",
"city_name": "Fontainebleau",
"country": "FR",
"latitude": 48.404766,
"longitude": 2.698759
},
"category": null,
"visio_url": null,
"mode": "online",
"local_begin_at": "@string@.isDateTime()",
"local_finish_at": "@string@.isDateTime()",
"image_url": null,
"link": "@string@.isUrl()",
"user_registered_at": null,
"object_state": "full"
}
"""

Scenario Outline: As a (delegated) referent I can get one event with full info
Given I am logged with "<user>" via OAuth client "JeMengage Web" with scope "jemengage_admin"
When I send a "GET" request to "/api/v3/events/0e5f9f02-fa33-4c2c-a700-4235d752315b?scope=<scope>"
Expand Down
6 changes: 2 additions & 4 deletions src/Api/Doctrine/EventExtension.php
Expand Up @@ -52,7 +52,7 @@ public function applyToCollection(
return;
}

$this->modifyQuery($queryBuilder, $context);
$this->modifyQuery($queryBuilder, $context, BaseEvent::STATUS_SCHEDULED);

$alias = $queryBuilder->getRootAliases()[0];

Expand Down Expand Up @@ -88,7 +88,7 @@ public function applyToCollection(
}
}

private function modifyQuery(QueryBuilder $queryBuilder, array $context): void
private function modifyQuery(QueryBuilder $queryBuilder, array $context, ?string $eventStatus = null): void
{
$alias = $queryBuilder->getRootAliases()[0];

Expand All @@ -97,8 +97,6 @@ private function modifyQuery(QueryBuilder $queryBuilder, array $context): void
->setParameter('true', true)
;

$eventStatus = BaseEvent::STATUS_SCHEDULED;

if (EventContextBuilder::CONTEXT_PUBLIC_ANONYMOUS === $context[EventContextBuilder::CONTEXT_KEY]) {
$queryBuilder
->andWhere("$alias.visibility IN (:public_visibilities)")
Expand Down

0 comments on commit b4548f6

Please sign in to comment.