mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-12 13:26:47 +00:00
17 lines
575 B
Python
17 lines
575 B
Python
def get_bookings(place):
|
|
"""
|
|
returns a list of all related place reservations
|
|
"""
|
|
booked_dates = Reservation.objects.all()
|
|
return [booking for booking in booked_dates if booking.place.name == f"{place.name}"]
|
|
|
|
|
|
def check_availability(place, start_date, end_date):
|
|
"""
|
|
check if the related place is available during a given period
|
|
"""
|
|
bookings = get_bookings(place)
|
|
for booking in bookings:
|
|
if (booking.start <= start_date <= booking.end) or (booking.start <= end_date <= booking.end):
|
|
return False
|
|
return True
|