Пример #1
0
def create_stock_with_thing_offer(
    offerer: Offerer,
    venue: Venue,
    offer: Offer = None,
    price: Optional[Decimal] = 10,
    quantity: int = 50,
    name: str = "Test Book",
    booking_email: str = "*****@*****.**",
    soft_deleted: bool = False,
    url: str = None,
    booking_limit_datetime: datetime = None,
    thing_type: ThingType = ThingType.AUDIOVISUEL,
) -> Stock:
    stock = Stock()
    stock.offerer = offerer
    stock.price = price

    if offer:
        stock.offer = offer
    else:
        stock.offer = create_offer_with_thing_product(venue,
                                                      thing_name=name,
                                                      thing_type=thing_type)

    stock.offer.bookingEmail = booking_email
    stock.bookingLimitDatetime = booking_limit_datetime
    stock.offer.url = url
    stock.offer.venue = venue
    stock.quantity = quantity
    stock.isSoftDeleted = soft_deleted

    return stock
Пример #2
0
def create_stock_with_event_offer(
        offerer: Offerer,
        venue: Venue,
        price: int = 10,
        booking_email: str = "*****@*****.**",
        quantity: int = 10,
        is_soft_deleted: bool = False,
        event_type: EventType = EventType.JEUX,
        name: str = "Mains, sorts et papiers",
        offer_id: int = None,
        beginning_datetime: datetime = datetime.utcnow() + timedelta(hours=72),
        thumb_count: int = 0,
        booking_limit_datetime: datetime = datetime.utcnow() +
    timedelta(hours=71),
        date_created: datetime = datetime.utcnow(),
        date_modified_at_last_provider: datetime = datetime.utcnow(),
        date_modifed: datetime = datetime.utcnow(),
) -> Stock:
    stock = Stock()
    stock.offerer = offerer
    stock.price = price
    stock.quantity = quantity
    stock.beginningDatetime = beginning_datetime
    stock.bookingLimitDatetime = booking_limit_datetime
    stock.dateCreated = date_created
    stock.dateModifiedAtLastProvider = date_modified_at_last_provider
    stock.dateModified = date_modifed
    stock.offer = create_offer_with_event_product(
        venue,
        event_name=name,
        event_type=event_type,
        booking_email=booking_email,
        is_national=False,
        thumb_count=thumb_count,
    )
    stock.offer.id = offer_id
    stock.isSoftDeleted = is_soft_deleted

    return stock