Skip to content

Commit

Permalink
(PC-31951)[API] fix: Event products can only be of type SEANCE_CINE
Browse files Browse the repository at this point in the history
  • Loading branch information
R0ntheo committed Sep 19, 2024
1 parent b4bbbdc commit cea04d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api/src/pcapi/core/offers/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ class Meta:
class EventProductFactory(ProductFactory):
subcategoryId = subcategories.SEANCE_CINE.id

@classmethod
def _create(
cls,
model_class: type[models.Offer],
*args: typing.Any,
**kwargs: typing.Any,
) -> models.Product:
if kwargs["subcategoryId"] != subcategories.SEANCE_CINE.id:
raise ValueError("Events products subcategory can only be SEANCE_CINE")
return super()._create(model_class, *args, **kwargs)


class ThingProductFactory(ProductFactory):
subcategoryId = subcategories.SUPPORT_PHYSIQUE_FILM.id
Expand Down

0 comments on commit cea04d7

Please sign in to comment.