fix fixa rezerwacji

This commit is contained in:
Hokan 2019-01-23 00:04:23 +01:00
parent 037ab2737a
commit 646e675910
3 changed files with 3 additions and 5 deletions

Binary file not shown.

View File

@ -30,7 +30,6 @@ def reservation(request):
template = loader.get_template('reservation.html') template = loader.get_template('reservation.html')
error = "" error = ""
reservation = Reservation.objects.filter(room_number=room_number).filter(begin_date__gte=begin_date).filter(end_date__lte=end_date) reservation = Reservation.objects.filter(room_number=room_number).filter(begin_date__gte=begin_date).filter(end_date__lte=end_date)
print(reservation)
if reservation: if reservation:
status = "Pokój " + str(room_number) + " jest już zarezerwowany" status = "Pokój " + str(room_number) + " jest już zarezerwowany"
return HttpResponse(template.render({'status': status}, request)) return HttpResponse(template.render({'status': status}, request))
@ -39,11 +38,10 @@ def reservation(request):
if request.method == "POST": if request.method == "POST":
try: try:
client_id = request.POST['id_number'] client_id = request.POST['id_number']
if check(client_id):
instance = Client.objects.get(id_number=client_id)
client = ClientForm(request.POST, instance=instance)
if not Client.objects.get(id_number=client_id): if check(client_id):
if Client.objects.filter(id_number=client_id).first() is None:
client = ClientForm(request.POST)
client.save() client.save()
r = Reservation() r = Reservation()