diff --git a/api/src/pcapi/core/offers/factories.py b/api/src/pcapi/core/offers/factories.py index b033b39efa2..051489aac11 100644 --- a/api/src/pcapi/core/offers/factories.py +++ b/api/src/pcapi/core/offers/factories.py @@ -217,11 +217,6 @@ def _create( return super()._create(model_class, *args, **kwargs) - @factory.post_generation - def is_headline_offer(self, create: bool, is_headline_offer: bool = False, **kwargs: typing.Any) -> None: - if is_headline_offer: - HeadlineOfferFactory(offer=self, venue=self.venue) - class ArtistProductLinkFactory(BaseFactory): class Meta: diff --git a/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_event_offers.py b/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_event_offers.py index 73cc7b8b74f..131cc7b7f83 100644 --- a/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_event_offers.py +++ b/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_event_offers.py @@ -4,6 +4,7 @@ import pcapi.core.offerers.models as offerers_models import pcapi.core.offers.factories as offers_factories import pcapi.core.offers.models as offers_models +from pcapi.models.offer_mixin import OfferStatus from pcapi.repository import repository from pcapi.sandboxes.scripts.mocks.event_mocks import MOCK_NAMES @@ -59,11 +60,19 @@ def create_industrial_event_offers( ), isActive=is_active, isDuo=is_duo, - is_headline_offer=bool(headline_offer_limit_per_offerer and not event_venue.has_headline_offer), + ) + if ( + headline_offer_limit_per_offerer + and event_offers_by_name[name].status == OfferStatus.ACTIVE + and not event_venue.has_headline_offer + ): + offers_factories.HeadlineOfferFactory(offer=event_offers_by_name[name], venue=event_venue) + headline_offer_limit_per_offerer = ( + headline_offer_limit_per_offerer - 1 + if headline_offer_limit_per_offerer > 0 + else headline_offer_limit_per_offerer ) offer_index += 1 - # FIXME : 6.12.2024 ogeber : decrement headline_offer_limit_per_offerer (limit 0) if original limit is > 1 - headline_offer_limit_per_offerer = 0 event_index += EVENTS_PER_OFFERER_WITH_PHYSICAL_VENUE diff --git a/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_thing_offers.py b/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_thing_offers.py index 8d99d38df1d..91d76a07bef 100644 --- a/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_thing_offers.py +++ b/api/src/pcapi/sandboxes/scripts/creators/industrial/create_industrial_thing_offers.py @@ -4,6 +4,7 @@ import pcapi.core.offerers.models as offerers_models import pcapi.core.offers.factories as offers_factories import pcapi.core.offers.models as offers_models +from pcapi.models.offer_mixin import OfferStatus from pcapi.repository import repository from pcapi.sandboxes.scripts.mocks.thing_mocks import MOCK_NAMES @@ -65,12 +66,21 @@ def create_industrial_thing_offers( url="http://example.com" if subcategory.is_online_only else None, idAtProvider=str(id_at_provider), extraData=offers_factories.build_extra_data_from_subcategory(subcategory.id, set_all_fields=False), - is_headline_offer=bool(headline_offer_limit_per_offerer and not thing_venue.has_headline_offer), + ) + if ( + headline_offer_limit_per_offerer + and thing_offers_by_name[name].status == OfferStatus.ACTIVE + and not thing_venue.has_headline_offer + ): + offers_factories.HeadlineOfferFactory(offer=thing_offers_by_name[name], venue=thing_venue) + offer_index += 1 + headline_offer_limit_per_offerer = ( + headline_offer_limit_per_offerer - 1 + if headline_offer_limit_per_offerer > 0 + else headline_offer_limit_per_offerer ) offer_index += 1 id_at_provider += 1 - # FIXME : 6.12.2024 ogeber : decrement headline_offer_limit_per_offerer (limit 0) if original limit is > 1 - headline_offer_limit_per_offerer = 0 thing_index += THINGS_PER_OFFERER