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 uo.validationToken == None \ and uo.offerer.validationToken == None: for venue in uo.offerer.managedVenues: for offer in venue.offers: if offer.isThing: for stock in offer.stocks: if stock.bookings: for booking in stock.bookings: if not booking.isUsed: return { "booking": get_booking_helper(booking), "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "user": get_user_helper(user), "venue": get_venue_helper(venue) }
def get_existing_pro_validated_user_with_not_validated_offerer_validated_user_offerer_and_validated_offerer_not_validated_user_offerer_and_validated_offerer_validated_user_offerer(): query = User.query.filter(User.validationToken == None) first_query = filter_users_with_at_least_one_not_validated_offerer_validated_user_offerer(query) second_query = filter_users_with_at_least_one_validated_offerer_not_validated_user_offerer(query) third_query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer(query) query = first_query.intersect_all(second_query, third_query) user = query.first() not_validated_offerer = [ uo.offerer for uo in user.UserOfferers if uo.offerer.validationToken != None \ and uo.validationToken == None ][0] validated_offerer_with_not_validated_user_offerer = [ uo.offerer for uo in user.UserOfferers if uo.offerer.validationToken == None \ and uo.validationToken != None ][0] validated_offerer_with_validated_user_offerer = [ uo.offerer for uo in user.UserOfferers if uo.offerer.validationToken == None \ and uo.validationToken == None ][0] return { "notValidatedOfferer": get_offerer_helper(not_validated_offerer), "offerersCount": len(user.UserOfferers), "user": get_user_helper(user), "validatedOffererWithNotValidatedUserOfferer": get_offerer_helper(validated_offerer_with_not_validated_user_offerer), "validatedOffererWithValidatedUserOfferer": get_offerer_helper(validated_offerer_with_validated_user_offerer) }
def get_existing_pro_validated_user_with_validated_offerer_with_iban_validated_user_offerer_with_thing_offer_with_stock( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(BankInformation) query = query.join(Venue, Venue.managingOffererId == Offerer.id) \ .join(Offer) \ .join(Offer.stocks) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None \ and uo.offerer.validationToken == None \ and uo.offerer.iban: for venue in uo.offerer.managedVenues: for offer in venue.offers: if offer.isThing and offer.stocks and offer.isEditable: return { "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "stock": get_stock_helper(offer.stocks[0]), "user": get_user_helper(user), "venue": get_venue_helper(venue) }
def get_existing_pro_validated_user_with_validated_offerer_with_iban_validated_user_offerer_with_event_offer_with_stock( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(BankInformation) query = query.join(Venue, Venue.managingOffererId == Offerer.id) \ .join(Offer) \ .join(Stock) \ .filter((Stock.beginningDatetime != None) & (Stock.endDatetime != None)) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None \ and uo.offerer.validationToken == None \ and uo.offerer.iban: for venue in uo.offerer.managedVenues: for offer in venue.offers: if offer.isEvent \ and offer.stocks: for stock in offer.stocks: if stock.beginningDatetime and stock.endDatetime: return { "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "stock": get_stock_helper(stock), "user": get_user_helper(user), "venue": get_venue_helper(venue) }
def get_existing_pro_validated_user_with_validated_offerer_with_iban_validated_user_offerer_with_event_offer_with_no_stock( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(BankInformation) query = query.join(Venue, Venue.managingOffererId == Offerer.id).join(Offer).filter( (Offer.type.in_([str(event_type) for event_type in EventType])) & \ (~Offer.stocks.any()) ) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None \ and uo.offerer.validationToken == None \ and uo.offerer.iban: for venue in uo.offerer.managedVenues: for offer in venue.offers: if offer.isEvent \ and len(offer.stocks) == 0: return { "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "user": get_user_helper(user), "venue": get_venue_helper(venue) }
def get_existing_pro_validated_user_with_validated_offerer_with_no_iban_validated_user_offerer_with_event_offer( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.filter(Offerer.bankInformation == None) query = query.join(Venue).join(Offer).filter( Offer.type.in_([str(thing_type) for thing_type in ThingType])) query = query.filter(Venue.isVirtual == False) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None \ and uo.offerer.validationToken == None \ and not uo.offerer.iban: for venue in uo.offerer.managedVenues: if not venue.isVirtual: for offer in venue.offers: if offer.isEvent: return { "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "user": get_user_helper(user), "venue": get_venue_helper(venue) }
def get_existing_pro_validated_user_with_validated_offerer_with_no_iban_validated_user_offerer_with_thing_offer_with_no_stock( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.filter(Offerer.bankInformation == None) query = query.join(Venue).filter(Venue.offers.any( (Offer.type.in_([str(thing_type) for thing_type in ThingType])) & \ (~Offer.stocks.any()) )) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None \ and uo.offerer.validationToken == None \ and not uo.offerer.iban: for venue in uo.offerer.managedVenues: for offer in venue.offers: if offer.isThing and len( offer.stocks) == 0 and offer.isEditable: return { "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "user": get_user_helper(user), "venue": get_venue_helper(venue) }
def get_existing_pro_validated_user_with_validated_offerer_validated_user_offerer_with_at_least_one_physical_venue(): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer(query) query = keep_offerers_with_at_least_one_physical_venue(query) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None and uo.offerer.validationToken == None: for venue in uo.offerer.managedVenues: if not venue.isVirtual: return { "offerer": get_offerer_helper(uo.offerer), "user": get_user_helper(user), "venue": get_venue_helper(venue) }
def get_existing_pro_validated_user_with_validated_offerer_validated_user_offerer(): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer(query) user = query.first() offerer = [ uo.offerer for uo in user.UserOfferers if uo.validationToken == None \ and uo.offerer.validationToken == None ][0] return { "offerer": get_offerer_helper(offerer), "user": get_user_helper(user) }
def get_existing_pro_validated_user_with_at_least_one_visible_activated_offer( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(Venue).join(Offer).filter(Offer.isActive == True) user = query.first() for uo in user.UserOfferers: if uo.offerer.validationToken == None and uo.validationToken == None: for venue in uo.offerer.managedVenues: for offer in venue.offers: if offer.isActive: return { "offer": get_offer_helper(offer), "user": get_user_helper(user) }
def get_existing_pro_validated_user_with_validated_offerer_validated_user_offerer_no_physical_venue(): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer(query) query = keep_offerers_with_no_physical_venue(query) user = query.first() offerer = [ uo.offerer for uo in user.UserOfferers if uo.offerer.validationToken == None \ and uo.validationToken == None \ and all([v.isVirtual for v in uo.offerer.managedVenues]) ][0] return { "offerer": get_offerer_helper(offerer), "user": get_user_helper(user) }
def get_existing_pro_validated_user_with_at_least_one_visible_offer(): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(Venue, Venue.managingOffererId == Offerer.id).join(Offer) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None and uo.offerer.validationToken == None: for venue in uo.offerer.managedVenues: if venue.offers: offer = venue.offers[0] return { "offer": get_offer_helper(offer), "user": get_user_helper(user) }
def get_existing_pro_validated_user_with_at_least_one_visible_offer_with_no_mediation( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(Venue) \ .join(Offer) \ .join(Mediation) user = query.first() for uo in user.UserOfferers: if uo.offerer.validationToken == None and uo.validationToken == None: for venue in uo.offerer.managedVenues: for offer in venue.offers: if len(offer.mediations) == 0: return { "offer": get_offer_helper(offer), "user": get_user_helper(user) }
def get_existing_pro_validated_user_with_validated_offerer_validated_user_offerer_with_event_offer( ): query = User.query.filter(User.validationToken == None) query = filter_users_with_at_least_one_validated_offerer_validated_user_offerer( query) query = query.join(Venue).join(Offer).filter( Offer.type.in_([str(event_type) for event_type in EventType])) user = query.first() for uo in user.UserOfferers: if uo.validationToken == None and uo.offerer.validationToken == None: for venue in uo.offerer.managedVenues: for offer in venue.offers: if offer.isEvent: return { "offer": get_offer_helper(offer), "offerer": get_offerer_helper(uo.offerer), "user": get_user_helper(user), "venue": get_venue_helper(venue) }