From a2bc0b224e16b4ed88aef0b203dc6e474c5ea8f7 Mon Sep 17 00:00:00 2001 From: Hokan Date: Sun, 13 Jan 2019 19:10:01 +0100 Subject: [PATCH] podpiecie przycisku pod backend --- hotel/db.sqlite3 | Bin 49152 -> 49152 bytes hotel/rooms/__pycache__/models.cpython-35.pyc | Bin 990 -> 1115 bytes hotel/rooms/__pycache__/urls.cpython-35.pyc | Bin 276 -> 317 bytes hotel/rooms/__pycache__/views.cpython-35.pyc | Bin 586 -> 1029 bytes hotel/rooms/models.py | 3 +++ hotel/rooms/templates/index.html | 10 +++++++--- hotel/rooms/templates/reservation.html | 10 ++++++++++ hotel/rooms/urls.py | 1 + hotel/rooms/views.py | 13 +++++++++++++ 9 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 hotel/rooms/templates/reservation.html diff --git a/hotel/db.sqlite3 b/hotel/db.sqlite3 index abcf31220e6bdbd5e2152888a82adfcaa1ce8dcb..0ba0880bf102ab1051f573d8bf0aa30550ccca6a 100644 GIT binary patch delta 30 mcmZo@U~Xt&o*>N_G*QNxHHbm?N_I8nx#HIPA1X2Zsm3A-6NHhn?ESPCBi diff --git a/hotel/rooms/__pycache__/models.cpython-35.pyc b/hotel/rooms/__pycache__/models.cpython-35.pyc index 930053f3509a00fa695e1cd465cb76f0e16a3e8f..386b93ffc3d810241369921ecd3c558d73b11837 100644 GIT binary patch delta 197 zcmcb|ew%|+jF*>dNu6~}&qhvhCdQh{icCfPDeMd_3=C0x3@IE8!J3?tr!g5gB{MQW z0ElJ+VrL*O<^>WZ3=B043|Wi}&5S_RjDDI-x0s7dif(Zi<>%+d=auFrr50&27I92| z$SAD94b&hD(g`wxfw77w2&hOeJ|3tcKHg80fAUEtb=D#=pxorYO!kc2lh-kePxfc# b5)l9j@i1~SvM~vdL6vpP8U_Z2$3P4RY(SO+5Eq9`RJKq|Wn@TUXGmpc$YNzk0U~yW zW+ujTCWa_Bh7=BlU`@`6=~@D}xQkMYQ;W(HOEUBG{507oPEnLD;sBa)i@UTary#MU dB(*57cqKy-H&CpId*W$FE|4t(OajcJi~zjZ9v=Vz delta 101 zcmdnXG=)i7jF*>7CDSS`L(k-$lE75G)%PhALG= znO}iusS?rf6Ryo4VaACCsDXPh-v2`fUv}=ts_B`|Bve^0PCufIMlPljZKmEMVht+`jaGF^&HTI&s$coG1 z=W=rS`2DOHn`%p57rAkMm{*Sv{|D9$=QCfqG_f)m8#C15{@&=&@{D2E#c%yiZ*(2H z?A+9W^VZ79tqd{^ZCm&&fenG4K<6)XneA{}FFlCj1V97oP|Q1_zUnC}t?Z`B?Gqi) T;C4&B-bh&KQkOO>l9lx-Cg&B(y;m;nhe0oe{fTpTb_Ifyw}lXGK>KO?iBCg - - +
+ {% csrf_token %} + +
+ +
+
{% endif %} diff --git a/hotel/rooms/templates/reservation.html b/hotel/rooms/templates/reservation.html new file mode 100644 index 0000000..c0ba886 --- /dev/null +++ b/hotel/rooms/templates/reservation.html @@ -0,0 +1,10 @@ + + + + + Title + + +{{ status }} + + \ No newline at end of file diff --git a/hotel/rooms/urls.py b/hotel/rooms/urls.py index 3ef24d9..d0e1047 100644 --- a/hotel/rooms/urls.py +++ b/hotel/rooms/urls.py @@ -4,4 +4,5 @@ from . import views urlpatterns = [ path('', views.index, name='index'), + path('reservation', views.reservation, name='reservation') ] \ No newline at end of file diff --git a/hotel/rooms/views.py b/hotel/rooms/views.py index 5af244b..0b453ae 100644 --- a/hotel/rooms/views.py +++ b/hotel/rooms/views.py @@ -11,3 +11,16 @@ def index(request): template = loader.get_template('index.html') return HttpResponse(template.render({'rooms': rooms}, request)) + + +def reservation(request): + room = get_object_or_404(Room, room_number=request.POST['room']) + template = loader.get_template('reservation.html') + if not room.reserved: + room.reserved = True + room.save() + status = "Pokój " + str(room) + " zarezerwowany pomyślnie" + else: + status = "Pokój " + str(room) + " jest już zarezerwowany" + + return HttpResponse(template.render({'status': status}, request)) \ No newline at end of file