add adress

This commit is contained in:
Martin Quarda 2024-04-08 15:06:33 +02:00
parent 807734d28a
commit 85d542aa47
4 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2.11 on 2024-04-08 13:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('alkatorapi', '0003_alter_user_duration'),
]
operations = [
migrations.AddField(
model_name='user',
name='address',
field=models.CharField(default='', max_length=255),
preserve_default=False,
),
]

View File

@ -4,6 +4,7 @@ from django.db import models
class User(models.Model):
first_name = models.CharField(max_length=120)
last_name = models.CharField(max_length=120)
address = models.CharField(max_length=255)
email = models.EmailField(max_length=120)
date_of_birth = models.DateField()
register_date = models.DateTimeField(auto_now=True)

View File

@ -18,6 +18,8 @@ def register(request):
return HttpResponse('{"reason":"Přijmení je povinné!"}', status=400, content_type='application/json')
if not request.POST['email']:
return HttpResponse('{"reason":"Email je povinný!"}', status=400, content_type='application/json')
if not request.POST['address']:
return HttpResponse('{"reason":"Adresa je povinná!"}', status=400, content_type='application/json')
if User.objects.filter(email=request.POST['email']):
return HttpResponse('{"reason":"Email je již registrován!"}', status=400, content_type='application/json')
try:
@ -34,6 +36,7 @@ def register(request):
last_name=request.POST['last_name'],
email=request.POST['email'],
date_of_birth=dat,
address=request.POST['address'],
)
user.save()
return HttpResponse('{"success":"Úspěšná registrace."}', content_type='application/json')

View File

@ -174,6 +174,10 @@ class Main extends Component {
<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" max={new Date().toJSON().slice(0, 10)} />
</div>
<div class="mb-3">
<label for="address" class="form-label">Adresa (kvůli fakturaci)</label>
<input type="text" class="form-control" id="address" name="address" />
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="agreement" name="agreement" />
<label class="form-check-label" for="agreement">Souhlas se <a href="/public/ochrana_osobnich_udaju.pdf">zpracováním osobních údajů</a> a <a href="/public/reverz.pdf">podmínkami závodu</a>.</label>