mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-12 13:26:47 +00:00
18 lines
539 B
Python
18 lines
539 B
Python
def get_reservation_price(place, start, end):
|
|
"""
|
|
Compute booking price as a function of place and dates
|
|
"""
|
|
nights = (end - start).days
|
|
return place.price * nights
|
|
|
|
|
|
if __name__ == '__main__':
|
|
from rental.models import Place
|
|
from datetime import *
|
|
from django.shortcuts import get_object_or_404
|
|
place_name = 'T2'
|
|
place = get_object_or_404(Place, name=place_name)
|
|
start = datetime(2019, 11, 14)
|
|
end = datetime(2019, 11, 20)
|
|
x = get_reservation_price(place_name, start, end)
|
|
print(x)
|