diff --git a/alkatorapi/views.py b/alkatorapi/views.py index a7b5978..812e894 100644 --- a/alkatorapi/views.py +++ b/alkatorapi/views.py @@ -190,13 +190,21 @@ def change_racer(request): return HttpResponse('{"reason":"Jméno je povinné!"}', status=400, content_type='application/json') if not request.POST['last_name']: return HttpResponse('{"reason":"Přijmení je povinné!"}', status=400, content_type='application/json') + try: + dat = datetime.strptime(request.POST['date_of_birth'], "%Y-%m-%d").date() + if dat > date(2006, 10, 5): + return HttpResponse('{"reason":"Je potřeba mít 18 let v den závodu!"}', status=400, content_type='application/json') + elif dat < date(1924, 10, 5): + 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') racer = Racer.objects.get(request.POST['invoice_id']) racer.first_name = request.POST['first_name'] racer.last_name = request.POST['last_name'] racer.email = request.POST['email'] racer.phone = request.POST['phone'] racer.team = request.POST['team'] - racer.date_of_birth = request.POST['date_of_birth'] + racer.date_of_birth = dat racer.save() return HttpResponse('{"success":"Úspěšně uloženo."}', content_type='application/json') except MultiValueDictKeyError: diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index e5de0f6..0ec385e 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -19,6 +19,8 @@ class Main extends Component { status_text: "", status: "", faq: false, + racer: {}, + showRacerModalWindow: false, results: [], gallery_open: undefined, page: window.location.hash, @@ -65,6 +67,12 @@ class Main extends Component { onHashChange(event){ this.setState({page: window.location.hash, gallery_open: undefined}) } + editRacer = (racer) => { + this.setState({ + racer: racer, + showRacerModalWindow: true, + }) + } onSubmit(event){ event.preventDefault(); let form = document.getElementById("form"); @@ -223,7 +231,7 @@ class Main extends Component { {racer.date_of_birth} {racer.phone} {racer.paid?"Zaplatil":"Nezaplatil"} - + )} @@ -349,8 +357,43 @@ class Main extends Component { } {this.state.page == "" &&
- {this.state.faq && + {(this.state.faq || this.state.showRacerModalWindow) &&
} + {this.state.showRacerModalWindow && +
this.setState({showRacerModalWindow: false})}> +
e.stopPropagation()}> +
this.onSubmit(e)}> +

Registrace Závodníka

+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ } {this.state.faq &&
this.togglefaq()}>
e.stopPropagation()}>