format daty + sortowanie + wyglad w tabeli

This commit is contained in:
Łukasz Jędyk 2019-01-26 19:39:48 +01:00
parent ffd81453b7
commit 7f0efb044e
5 changed files with 1323 additions and 5 deletions

Binary file not shown.

1311
hotel/rooms/static/jquery-ui.css vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,11 @@
<html lang="en"> <html lang="en">
<head> <head>
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'jquery-ui.css' %}">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Hotel INO Scrum</title> <title>Hotel INO Scrum</title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script> <script>
function changeBackground(imageUrl) { function changeBackground(imageUrl) {
if(imageUrl != null) { if(imageUrl != null) {
@ -13,6 +16,10 @@
localStorage.backgroundImage = imageUrl; localStorage.backgroundImage = imageUrl;
} }
} }
$( function() {
$( ".datepicker" ).datepicker({ dateFormat: 'dd-mm-yy' }).val();
} );
</script> </script>
</head> </head>
<body onLoad="changeBackground(imageUrl = localStorage.backgroundImage)"> <body onLoad="changeBackground(imageUrl = localStorage.backgroundImage)">
@ -39,8 +46,8 @@
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="room" value="{{ room.room_number }}"> <input type="hidden" name="room" value="{{ room.room_number }}">
<div class="button-box" > <div class="button-box" >
Od: <input type="date" name="begindate"> Od: <input type="text" class="datepicker" name="begindate" size="3">
Do: <input type="date" name="enddate"><br> Do: <input type="text" class="datepicker" name="enddate" size="3">
<button>Rezerwuj</button> <button>Rezerwuj</button>
</div> </div>
</form> </form>

View File

@ -12,7 +12,7 @@ import datetime
def index(request): def index(request):
rooms = Room.objects.all() rooms = Room.objects.all()
rooms = rooms.order_by('room_number') rooms = rooms.order_by('room_type', 'room_number')
template = loader.get_template('index.html') template = loader.get_template('index.html')
return HttpResponse(template.render({'rooms': rooms}, request)) return HttpResponse(template.render({'rooms': rooms}, request))
@ -21,8 +21,8 @@ def index(request):
def reservation(request): def reservation(request):
room_number, begin_date, end_date = request.POST['room'], request.POST['begindate'], request.POST['enddate'] room_number, begin_date, end_date = request.POST['room'], request.POST['begindate'], request.POST['enddate']
try: try:
begin_datetime = datetime.datetime.strptime(begin_date, "%Y-%m-%d") begin_datetime = datetime.datetime.strptime(begin_date, "%d-%m-%Y")
end_datetime = datetime.datetime.strptime(end_date, "%Y-%m-%d") end_datetime = datetime.datetime.strptime(end_date, "%d-%m-%Y")
except: except:
return HttpResponse(loader.get_template('error.html').render({'error': "Błąd przy datach"}, request)) return HttpResponse(loader.get_template('error.html').render({'error': "Błąd przy datach"}, request))
if begin_datetime == '' or end_datetime == '' or end_datetime < begin_datetime or begin_datetime < datetime.datetime.today() or end_datetime < datetime.datetime.today(): if begin_datetime == '' or end_datetime == '' or end_datetime < begin_datetime or begin_datetime < datetime.datetime.today() or end_datetime < datetime.datetime.today():