diff --git a/jauns_projekts/jauns_projekts/urls.py b/jauns_projekts/jauns_projekts/urls.py index 7a47b87..cef3bfc 100644 --- a/jauns_projekts/jauns_projekts/urls.py +++ b/jauns_projekts/jauns_projekts/urls.py @@ -22,5 +22,6 @@ urlpatterns = [ path('admin/', admin.site.urls), path('show-hello', uzdevumi.views.show_hello), path('show-html', uzdevumi.views.show_html), + path('university', uzdevumi.views.form), ] diff --git a/jauns_projekts/templates/form.html b/jauns_projekts/templates/form.html index d08b453..9261f4c 100644 --- a/jauns_projekts/templates/form.html +++ b/jauns_projekts/templates/form.html @@ -7,8 +7,10 @@
{% csrf_token %} - First name: - Last name: + Full name:
+ Mathematics:
+ Latvian language:
+ Foreign language:
diff --git a/jauns_projekts/templates/hello.html b/jauns_projekts/templates/hello.html index d144d19..2245177 100644 --- a/jauns_projekts/templates/hello.html +++ b/jauns_projekts/templates/hello.html @@ -6,5 +6,7 @@

Current datetime: {{ dateadntime }}

+

Current datetime: {{ dateadntime }}

+ \ No newline at end of file diff --git a/jauns_projekts/uzdevumi/views.py b/jauns_projekts/uzdevumi/views.py index 393a650..5b1a9b1 100644 --- a/jauns_projekts/uzdevumi/views.py +++ b/jauns_projekts/uzdevumi/views.py @@ -2,6 +2,7 @@ from django.shortcuts import render from django.http import HttpResponse from datetime import datetime + # Create your views here. def show_hello(request): return HttpResponse('Hello!') @@ -21,11 +22,11 @@ def show_html(request): context=context, ) -def show_name(request): +def show_name(request): # ja submit, tad metode POST if request.method == 'POST': - # input nosaukums + # input nosaukums first_name = request.POST['first_name'] last_name = request.POST['last_name'] @@ -36,3 +37,22 @@ def show_name(request): request, template_name='form.html', ) + +def form(request): + # ja submit, tad metode POST + if request.method == 'POST': + # input nosaukums + fullname = request.POST['fullname'] + mathematics = int(request.POST['mathematics']) + latvian_lng = int(request.POST['latvian_lng']) + foreign_lng = int(request.POST['foreign_lng']) + if mathematics < 40 or latvian_lng < 40 or foreign_lng < 40: + return HttpResponse(f'{fullname} can not apply to university') + else: + return HttpResponse(f'Hello, {fullname}! You can apply to our university. Your grades: Mathematics: {mathematics}, Latviesu vld: {latvian_lng}, Svesvaloda: {foreign_lng}') + + # šis parādās pie metodes GET (kad ievadam /show-name) + return render( + request, + template_name='form.html', + ) \ No newline at end of file