def create_offer_with_event_product(venue=None, product=None, event_name='Test event', duration_minutes=60, date_created=datetime.utcnow(), booking_email='*****@*****.**', thumb_count=0, dominant_color=None, event_type=EventType.SPECTACLE_VIVANT, is_national=False, is_active=True, idx=None, last_provider_id=None, id_at_providers=None, description=None) -> Offer: offer = Offer() if product is None: product = create_product_with_event_type(event_name=event_name, event_type=event_type, duration_minutes=duration_minutes, thumb_count=thumb_count, dominant_color=dominant_color, is_national=is_national) offer.product = product offer.venue = venue offer.name = product.name offer.type = product.type offer.description = description offer.isNational = product.isNational offer.durationMinutes = product.durationMinutes offer.dateCreated = date_created offer.bookingEmail = booking_email offer.isActive = is_active offer.id = idx offer.lastProviderId = last_provider_id offer.idAtProviders = id_at_providers return offer
def create_offer_with_thing_product(venue, product=None, date_created=datetime.utcnow(), booking_email='*****@*****.**', thing_type=ThingType.AUDIOVISUEL, thing_name='Test Book', media_urls=['test/urls'], author_name='Test Author', description=None, thumb_count=1, dominant_color=None, url=None, is_national=False, is_active=True, id_at_providers=None, idx=None, last_provider_id=None) -> Offer: offer = Offer() if product: offer.product = product offer.productId = product.id offer.name = product.name offer.type = product.type offer.mediaUrls = product.mediaUrls offer.extraData = product.extraData offer.url = product.url offer.isNational = product.isNational offer.description = product.description else: offer.product = create_product_with_thing_type(thing_name=thing_name, thing_type=thing_type, media_urls=media_urls, author_name=author_name, url=url, thumb_count=thumb_count, dominant_color=dominant_color, is_national=is_national, description=description) offer.name = thing_name offer.type = str(thing_type) offer.mediaUrls = media_urls offer.extraData = {'author': author_name} offer.url = url offer.isNational = is_national offer.description = description offer.venue = venue offer.dateCreated = date_created offer.bookingEmail = booking_email offer.isActive = is_active offer.lastProviderId = last_provider_id if id_at_providers: offer.idAtProviders = id_at_providers elif venue is not None: offer.idAtProviders = "%s@%s" % (offer.product.idAtProviders, venue.siret or venue.id) offer.id = idx return offer