date of birth
This commit is contained in:
parent
c4cd2e16a0
commit
32b15caef4
@ -1,7 +1,7 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from datetime import date
|
from datetime import date, datetime
|
||||||
|
|
||||||
from .models import User
|
from .models import User
|
||||||
|
|
||||||
@ -14,6 +14,15 @@ def register(request):
|
|||||||
return HttpResponse('{"reason":"Je potřeba souhlasit se zpracováním údajů!"}', status=400, content_type='application/json')
|
return HttpResponse('{"reason":"Je potřeba souhlasit se zpracováním údajů!"}', status=400, content_type='application/json')
|
||||||
if User.objects.filter(email=request.POST['email']):
|
if User.objects.filter(email=request.POST['email']):
|
||||||
return HttpResponse('{"reason":"Email je již registrován!"}', status=400, content_type='application/json')
|
return HttpResponse('{"reason":"Email je již registrován!"}', status=400, content_type='application/json')
|
||||||
|
try:
|
||||||
|
dat = datetime.strptime(request.POST['date_of_birth'], "%d/%m/%Y").date()
|
||||||
|
if dat > date(2006, 5, 4):
|
||||||
|
return HttpResponse('{"reason":"Je potřeba mít 18 let v den závodu!"}', status=400, content_type='application/json')
|
||||||
|
elif dat < date(1924, 5, 4):
|
||||||
|
return HttpResponse('{"reason":"Opravdu vám je 100 let?"}', status=400, content_type='application/json')
|
||||||
|
except:
|
||||||
|
return HttpResponse('{"reason":"Špatný formát datu narození!"}', status=400, content_type='application/json')
|
||||||
|
|
||||||
user = User(first_name=request.POST['first_name'], last_name=request.POST['last_name'], email=request.POST['email'])
|
user = User(first_name=request.POST['first_name'], last_name=request.POST['last_name'], email=request.POST['email'])
|
||||||
user.save()
|
user.save()
|
||||||
return HttpResponse('{"success":"Úspěšná registrace."}', content_type='application/json')
|
return HttpResponse('{"success":"Úspěšná registrace."}', content_type='application/json')
|
||||||
|
@ -89,6 +89,10 @@ class Main extends Component {
|
|||||||
<label for="email" class="form-label">Emailová adresa</label>
|
<label for="email" class="form-label">Emailová adresa</label>
|
||||||
<input type="email" class="form-control" id="email" name="email" />
|
<input type="email" class="form-control" id="email" name="email" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="date_of_birth" class="form-label">Datum narození</label>
|
||||||
|
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" />
|
||||||
|
</div>
|
||||||
<div class="mb-3 form-check">
|
<div class="mb-3 form-check">
|
||||||
<input type="checkbox" class="form-check-input" id="agreement" name="agreement" />
|
<input type="checkbox" class="form-check-input" id="agreement" name="agreement" />
|
||||||
<label class="form-check-label" for="agreement">Souhlas se zpracováním osobních údajů</label>
|
<label class="form-check-label" for="agreement">Souhlas se zpracováním osobních údajů</label>
|
||||||
|
@ -5,22 +5,29 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.logo{
|
.logo{
|
||||||
width: calc(100% - 20px);
|
width: 100%;
|
||||||
background:rgba(255,255,255,0.4);
|
background:rgba(255,255,255,0.4);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 10px;
|
margin: 10px 0;
|
||||||
border-radius: 40px;
|
border-radius: 40px;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.container{
|
||||||
|
background:rgba(255,255,255,0.4);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.val{
|
.val{
|
||||||
margin:10px;
|
margin:10px 0;
|
||||||
background:rgba(255,255,255,0.7);
|
background:rgba(255,255,255,0.7);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text>p{
|
.text{
|
||||||
margin: 10px 0;
|
margin: 10px auto;
|
||||||
background:rgba(255,255,255,0.7);
|
background:rgba(255,255,255,0.7);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user