json right?
This commit is contained in:
parent
f8623b4db5
commit
c042594d57
@ -7,7 +7,7 @@ from .models import User
|
||||
def register(request):
|
||||
if date.today() >= date(2024, 4, 21):
|
||||
return HttpResponse("Too late!", status_code=400)
|
||||
if not request.POST['agreement']:
|
||||
if not request.POST.get('agreement'):
|
||||
raise HttpResponse("Je potřeba souhlasit se zpracováním údajů!", status_code=400)
|
||||
user = User(first_name=request.POST['first_name'], last_name=request.POST['last_name'], email=request.POST['email'])
|
||||
user.save()
|
||||
|
@ -18,9 +18,11 @@ class Main extends Component {
|
||||
event.preventDefault();
|
||||
let form = document.forms[0];
|
||||
let formData = new FormData(form);
|
||||
var object = {};
|
||||
formData.forEach((value, key) => object[key] = value);
|
||||
fetch("/api/register", {
|
||||
method:"POST",
|
||||
body: JSON.stringify(formData),
|
||||
body: JSON.stringify(object),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
@ -58,19 +60,19 @@ class Main extends Component {
|
||||
<form class="container" onSubmit={(e) => this.onSubmit(e)}>
|
||||
<h1>Registrace</h1>
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Jméno</label>
|
||||
<input type="text" class="form-control" id="name" />
|
||||
<label for="first_name" class="form-label">Jméno</label>
|
||||
<input type="text" class="form-control" id="first_name" name="first_name" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Přijmení</label>
|
||||
<input type="text" class="form-control" id="name" />
|
||||
<label for="last_name" class="form-label">Přijmení</label>
|
||||
<input type="text" class="form-control" id="last_name" name="last_name" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Emailová adresa</label>
|
||||
<input type="email" class="form-control" id="email" />
|
||||
<input type="email" class="form-control" id="email" name="email" />
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" id="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>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Odeslat</button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user