From bbc581422b41923f9c5b527fc658457e7e7dfac8 Mon Sep 17 00:00:00 2001 From: pnshiralkar Date: Sat, 9 May 2020 00:52:23 +0530 Subject: Added Get workshop_type_tnc API --- workshop_app/urls.py | 1 + workshop_app/views.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/workshop_app/urls.py b/workshop_app/urls.py index 4bb140c..bd10381 100644 --- a/workshop_app/urls.py +++ b/workshop_app/urls.py @@ -33,5 +33,6 @@ urlpatterns = [ url(r'^propose_workshop/$', views.propose_workshop), url(r'^workshop_types/$', views.workshop_type_list), url(r'^workshop_type_details/([1-9][0-9]*)$', views.workshop_type_details), + url(r'^workshop_type_tnc/(?P\d+)$', views.workshop_type_tnc, name='workshop_type_tnc'), url(r'^view_profile/([1-9][0-9]*)$', views.view_comment_profile), ] diff --git a/workshop_app/views.py b/workshop_app/views.py index 5d0525c..e6876c7 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -1,3 +1,5 @@ +from django.http import JsonResponse, Http404 + try: from StringIO import StringIO as string_io except ImportError: @@ -6,7 +8,7 @@ from datetime import datetime from django.contrib.auth import login, logout, authenticate from django.contrib.auth.decorators import login_required -from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger +from django.core.paginator import Paginator from django.shortcuts import render, redirect from django.utils import timezone @@ -351,6 +353,16 @@ def workshop_type_details(request, workshop_type_id): ) +@login_required +def workshop_type_tnc(request, workshop_type_id): + workshop_type = WorkshopType.objects.filter(id=workshop_type_id) + if workshop_type.exists(): + workshop_type = workshop_type.first() + return JsonResponse({'tnc': workshop_type.terms_and_conditions}) + else: + raise Http404 + + def workshop_type_list(request): """Gives the details for types of workshops.""" user = request.user -- cgit From a8c4b770e9c57612cb1857bfef7cf0d1edd0b775 Mon Sep 17 00:00:00 2001 From: pnshiralkar Date: Sat, 9 May 2020 01:49:45 +0530 Subject: Added JS AJAX func to fetch tnc and modal to display --- .../templates/workshop_app/propose_workshop.html | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/workshop_app/templates/workshop_app/propose_workshop.html b/workshop_app/templates/workshop_app/propose_workshop.html index 678d11e..5ebc435 100644 --- a/workshop_app/templates/workshop_app/propose_workshop.html +++ b/workshop_app/templates/workshop_app/propose_workshop.html @@ -26,6 +26,20 @@ maxDate: upto, beforeShowDay: $.datepicker.noWeekends, }); + + + $('#disp_tnc').click(function (e) { + e.preventDefault() + if ($('#id_workshop_type').val() === '') + $('.modal-body').html("

Please select a workshop_type first!

") + else + $.ajax({ + url: '/workshop_type_tnc/' + $('#id_workshop_type').val(), + success: function (data) { + $('.modal-body').html(data.tnc) + } + }) + }) }); {% endblock %} @@ -36,6 +50,10 @@ .errorlist { color: red; } + + .modal-open .modal{ + overflow-y: hidden; + }
@@ -59,7 +77,9 @@
{{ form.date }}
- {{ form.tnc_accepted }} I accept the terms and conditions + {{ form.tnc_accepted }} I accept the terms and + conditions
{% if form.errors %}
@@ -78,4 +98,24 @@
+ + {% endblock %} \ No newline at end of file -- cgit