def get_existing_pro_validated_user_with_validated_offerer_with_reimbursement( ): query = (Payment.query.join(Booking).join(Stock).join(Offer).join( Venue).join(Offerer).join(UserOfferer).filter( (Offerer.validationToken == None) & (UserOfferer.validationToken == None)).join(User).filter( User.validationToken == None)) payment = query.first() booking = payment.booking stock = booking.stock offer = stock.offer venue = offer.venue offerer = venue.managingOfferer user = [ uo.user for uo in offerer.UserOfferers if uo.user.validationToken == None ][0] return { "booking": get_booking_helper(booking), "offer": get_offer_helper(offer), "offerer": get_offerer_helper(offerer), "payment": get_payment_helper(payment), "stock": get_stock_helper(stock), "user": get_pro_helper(user), "venue": get_venue_helper(venue), }
def get_existing_pro_validated_user_with_validated_offerer_with_validated_user_offerer_with_thing_offer_with_stock_with_not_used_booking( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(Venue).filter(Venue.offers.any(~Offer.stocks.any())) query = query.join(Offer).join(Stock).filter( Stock.bookings.any(Booking.isUsed == False)) user = query.first() for uo in user.UserOfferers: if not uo.isValidated or not uo.offerer.isValidated: continue for venue in uo.offerer.managedVenues: for offer in [o for o in venue.offers if o.isThing]: for stock in offer.stocks: for booking in [b for b in stock.bookings if not b.isUsed]: return { "booking": get_booking_helper(booking), "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "user": get_pro_helper(user), "venue": get_venue_helper(venue), } return None
def get_existing_pro_validated_user_with_validated_offerer_with_validated_user_offerer_with_thing_offer_with_stock_with_not_used_booking( ): user_offerer = offers_factories.UserOffererFactory() venue = offers_factories.VenueFactory(managingOfferer=user_offerer.offerer) offer = offers_factories.ThingOfferFactory(venue=venue, isActive=True) stock = offers_factories.StockFactory(offer=offer) booking = bookings_factories.IndividualBookingFactory(stock=stock, isUsed=False) return { "booking": get_booking_helper(booking), "user": get_pro_helper(user_offerer.user), }
def get_existing_pro_validated_user_with_validated_offerer_with_validated_user_offerer_with_eac_offer_with_stock_with_not_used_booking_validated_by_principal( ): user_offerer = offers_factories.UserOffererFactory() booking = bookings_factories.EducationalBookingFactory( dateCreated=datetime.datetime.utcnow() - datetime.timedelta(days=5), stock__offer__venue__managingOfferer=user_offerer.offerer, educationalBooking__status=EducationalBookingStatus.USED_BY_INSTITUTE, ) return { "booking": get_booking_helper(booking), "user": get_pro_helper(user_offerer.user), }
def get_existing_pro_validated_user_with_validated_offerer_with_booking(): query = (Booking.query.join(Stock).join(Offer).join(VenueSQLEntity).join( Offerer).join(UserOfferer).filter((Offerer.validationToken == None) & ( UserOfferer.validationToken == None)).join(User).filter( User.validationToken == None)) booking = query.first() stock = booking.stock offer = stock.offer venue = offer.venue offerer = venue.managingOfferer user = [ uo.user for uo in offerer.UserOfferers if uo.user.validationToken == None ][0] return { "booking": get_booking_helper(booking), "offer": get_offer_helper(offer), "offerer": get_offerer_helper(offerer), "stock": get_stock_helper(stock), "user": get_pro_helper(user), "venue": get_venue_helper(venue), }