diff options
-rw-r--r-- | workshop_app/templates/workshop_app/base.html | 10 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/propose_workshop.html | 42 | ||||
-rw-r--r-- | workshop_app/urls.py | 5 | ||||
-rw-r--r-- | workshop_app/views.py | 16 |
4 files changed, 61 insertions, 12 deletions
diff --git a/workshop_app/templates/workshop_app/base.html b/workshop_app/templates/workshop_app/base.html index c7a454e..ae404e7 100644 --- a/workshop_app/templates/workshop_app/base.html +++ b/workshop_app/templates/workshop_app/base.html @@ -43,20 +43,20 @@ <ul class="navbar-nav mr-auto"> {% if request.user.profile.position == 'coordinator' %} <li class="nav-item"> - <a class="nav-link" href="/my_workshops/">Workshop Status</a> + <a class="nav-link" href="{% url 'workshop_status_instructor' %}">Workshop Status</a> </li> <li class="nav-item"> - <a class="nav-link" href="/propose_workshop/">Propose Workshop</a> + <a class="nav-link" href="{% url 'propose_workshop' %}">Propose Workshop</a> </li> <li class="nav-item"> - <a class="nav-link" href="/workshop_types/">Workshop Types</a> + <a class="nav-link" href="{% url 'workshop_type_list' %}">Workshop Types</a> </li> {% elif request.user.profile.position == 'instructor' %} <li class="nav-item"> - <a class="nav-link" href="/my_workshops/">Workshop Status</a> + <a class="nav-link" href="{% url 'workshop_status_instructor' %}">Workshop Status</a> </li> <li class="nav-item"> - <a class="nav-link" href="/workshop_types/">Workshop Types</a> + <a class="nav-link" href="{% url 'workshop_type_list' %}">Workshop Types</a> </li> {% endif %} </ul> 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("<p class='text-danger'>Please select a workshop_type first!</p>") + else + $.ajax({ + url: '/workshop_type_tnc/' + $('#id_workshop_type').val(), + success: function (data) { + $('.modal-body').html(data.tnc) + } + }) + }) }); </script> {% endblock %} @@ -36,6 +50,10 @@ .errorlist { color: red; } + + .modal-open .modal{ + overflow-y: hidden; + } </style> <div class="container" align="center"> @@ -59,7 +77,9 @@ <br> {{ form.date }} <br> - {{ form.tnc_accepted }} I accept the <a href="/tnc">terms and conditions</a> + {{ form.tnc_accepted }} I accept the <a href="#" id="disp_tnc" data-toggle="modal" + data-target="#exampleModalCenter">terms and + conditions</a> <br> {% if form.errors %} <br> @@ -78,4 +98,24 @@ <br> </div> + <!-- Modal --> + <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" + aria-labelledby="exampleModalCenterTitle" aria-hidden="true"> + <div class="modal-dialog modal-dialog-centered" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="exampleModalLongTitle">Terms and Conditions</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body"> + + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> + </div> + </div> + </div> + </div> {% endblock %}
\ No newline at end of file diff --git a/workshop_app/urls.py b/workshop_app/urls.py index 0e90ee3..a083e5a 100644 --- a/workshop_app/urls.py +++ b/workshop_app/urls.py @@ -29,10 +29,11 @@ urlpatterns = [ url(r'^dashboard$', views.workshop_status_instructor, name='workshop_status_instructor'), url(r'^accept_workshop/(?P<workshop_id>\d+)', views.accept_workshop, name='accept_workshop'), url(r'^change_workshop_date/(?P<workshop_id>\d+)$', views.change_workshop_date, name='change_workshop_date'), - url(r'^propose_workshop/$', views.propose_workshop), + url(r'^propose_workshop/$', views.propose_workshop, name='propose_workshop'), url(r'^add_workshop_type$', views.add_workshop_type, name='add_workshop_type'), url(r'^delete_attachment_file/(?P<file_id>\d+)$', views.delete_attachment_file, name='delete_attachment_file'), - url(r'^workshop_types/$', views.workshop_type_list), + url(r'^workshop_types/$', views.workshop_type_list, name='workshop_type_list'), url(r'^workshop_type_details/(?P<workshop_type_id>\d+)$', views.workshop_type_details, name='workshop_type_details'), url(r'^view_profile/(?P<user_id>\d+)$', views.view_comment_profile, name='view_profile'), + url(r'^workshop_type_tnc/(?P<workshop_type_id>\d+)$', views.workshop_type_tnc, name='workshop_type_tnc'), ] diff --git a/workshop_app/views.py b/workshop_app/views.py index 620020a..05ebf94 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -1,5 +1,6 @@ -from django.forms import inlineformset_factory, model_to_dict from django.db.models import Q +from django.forms import inlineformset_factory, model_to_dict +from django.http import JsonResponse, Http404 from django.urls import reverse try: @@ -365,9 +366,6 @@ def workshop_type_details(request, workshop_type_id): file.cleaned_data['id'].delete() file.save() return redirect(reverse('workshop_type_details', args=[form_data.id])) - else: - print(request.POST) - print(form_file.errors) else: form = WorkshopTypeForm(instance=workshop_type) form_file = AttachmentFileFormSet() @@ -392,6 +390,16 @@ def delete_attachment_file(request, file_id): return redirect(reverse('workshop_type_list')) +@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 |