-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PC-29597)[API] chore : read duration minutes from produts #14596
base: master
Are you sure you want to change the base?
Changes from all commits
72a5457
171629f
4cc5344
0486699
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -540,7 +540,7 @@ def __table_args__(self): | |
sa.DateTime, nullable=True, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow | ||
) | ||
_description = sa.Column("description", sa.Text, nullable=True) | ||
durationMinutes = sa.Column(sa.Integer, nullable=True) | ||
_durationMinutes = sa.Column("durationMinutes", sa.Integer, nullable=True) | ||
externalTicketOfficeUrl = sa.Column(sa.String, nullable=True) | ||
extraData: OfferExtraData | None = sa.Column("jsonData", sa_mutable.MutableDict.as_mutable(postgresql.JSONB)) | ||
fieldsUpdated: list[str] = sa.Column( | ||
|
@@ -622,6 +622,19 @@ def description(self, value: str | None) -> None: | |
else: | ||
self._description = value | ||
|
||
@property | ||
def durationMinutes(self) -> int | None: | ||
if self.product: | ||
return self.product.durationMinutes | ||
return self._durationMinutes | ||
|
||
@durationMinutes.setter | ||
def durationMinutes(self, value: int | None) -> None: | ||
if self.product: | ||
self._durationMinutes = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On veut pas un warning ou autre pour dire que la fonction n'a pas l'effet escompté ? Voire une exception |
||
else: | ||
self._durationMinutes = value | ||
|
||
@property | ||
def isEducational(self) -> bool: | ||
return False | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,8 +55,7 @@ def synchronize(self) -> None: | |
|
||
product = self.get_or_create_movie_product(event) | ||
offer = self.get_or_create_offer(event, self.provider.id, self.venue) | ||
offer.product = product | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On veut garder cette ligne non ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je l'ai décalée plus bas dans le |
||
offer = self.fill_offer_attributes(offer, event) | ||
offer = self.fill_offer_attributes(offer, product, event) | ||
errors = entity_validator.validate(offer) | ||
if errors and len(errors.errors) > 0: | ||
self.created_objects -= 1 | ||
|
@@ -156,23 +155,23 @@ def get_or_create_offer( | |
self.created_objects += 1 | ||
return offer | ||
|
||
def fill_offer_attributes(self, offer: offers_models.Offer, event: ems_serializers.Event) -> offers_models.Offer: | ||
if event.title: | ||
offer.name = event.title | ||
if event.synopsis: | ||
offer.description = event.synopsis | ||
if event.duration: | ||
offer.durationMinutes = event.duration | ||
def fill_offer_attributes( | ||
self, offer: offers_models.Offer, product: offers_models.Product | None, event: ems_serializers.Event | ||
) -> offers_models.Offer: | ||
offer.isDuo = self.is_duo | ||
|
||
if offer.product: | ||
offer.name = offer.product.name | ||
offer.description = offer.product.description | ||
offer.durationMinutes = offer.product.durationMinutes | ||
if offer.product.extraData: | ||
if product: | ||
offer.name = product.name | ||
if product.extraData: | ||
offer.extraData = offer.extraData or offers_models.OfferExtraData() | ||
offer.extraData.update(offer.product.extraData) | ||
|
||
offer.extraData.update(product.extraData) | ||
offer.product = product | ||
else: | ||
if event.title: | ||
offer.name = event.title | ||
if event.synopsis: | ||
offer.description = event.synopsis | ||
if event.duration: | ||
offer.durationMinutes = event.duration | ||
return offer | ||
|
||
def get_or_create_stock( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
il n'y a pas de risque que le pro remplisse le champ et ne voit pas la modification attendue ?
Est-ce que l'on ne devrait pas lever une erreur explicite ?