diff options
Diffstat (limited to 'workshop_app')
-rw-r--r-- | workshop_app/models.py | 3 | ||||
-rw-r--r-- | workshop_app/static/workshop_app/js/overlay.js | 12 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/booking.html | 62 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/registeration_error.html | 2 | ||||
-rw-r--r-- | workshop_app/views.py | 79 |
5 files changed, 94 insertions, 64 deletions
diff --git a/workshop_app/models.py b/workshop_app/models.py index 096ce5d..03be064 100644 --- a/workshop_app/models.py +++ b/workshop_app/models.py @@ -87,12 +87,13 @@ class RequestedWorkshop(models.Model): User, related_name="%(app_label)s_%(class)s_related" ) + requested_workshop_date = models.DateField() status = models.CharField( max_length=32, default="Pending", choices=status_choices ) requested_workshop_title = models.ForeignKey( - Workshop, + Course, on_delete=models.CASCADE ) diff --git a/workshop_app/static/workshop_app/js/overlay.js b/workshop_app/static/workshop_app/js/overlay.js index 6563c0d..b4165c4 100644 --- a/workshop_app/static/workshop_app/js/overlay.js +++ b/workshop_app/static/workshop_app/js/overlay.js @@ -1,7 +1,7 @@ -function overlay(course_no) { - el = document.getElementById("overlay"); - course_id = document.getElementById("course_id"); - el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; +// function overlay(course_no) { +// el = document.getElementById("overlay"); +// course_id = document.getElementById("course_id"); +// el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; - console.log(course_no); -}
\ No newline at end of file +// console.log(course_no); +// }
\ No newline at end of file diff --git a/workshop_app/templates/workshop_app/booking.html b/workshop_app/templates/workshop_app/booking.html index 5089d77..153374a 100644 --- a/workshop_app/templates/workshop_app/booking.html +++ b/workshop_app/templates/workshop_app/booking.html @@ -5,31 +5,59 @@ {% endblock %} {% block extra %} - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> - - <script type="text/javascript"> + <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> + <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> + <script> function sendData(d){ + var $dialog = $('<div></div').html( + '<form id="myform" action="">\ + <input type="checkbox" id="one"\ + name="one" value="one"/>We will give minimum 50 participants for the workshop.<br/>\ + <input type="checkbox" id="two" name="two" value="two" />We agree that this booking won\'t be cancelled.<br/>\ + </form> ') + .dialog({ + autoOpen: false, + title: 'Terms & Condition', + buttons: { + "Confirm": function(){ + if($('#one').is(":checked") && $('#two').is(":checked")){ + booking_confirmed(d) + $(this).dialog("close"); + } else { + alert("Please select both the checkboxes"); + } + }, + "Cancel": function(){ + $(this).dialog("close"); + } + } + }); + + $dialog.dialog('open'); + } + +function booking_confirmed(d){ var URL = "{{ URL_ROOT }}/book_workshop/"; - console.log(d); - $.ajax({ - url: URL, - type: "POST", - data: { - d, - csrfmiddlewaretoken: $("input[name=csrfmiddlewaretoken]").val() - }, - - success:function(response){ - alert("success: " + response); - } - }); + $.ajax({ + url: URL, + type: "POST", + data: { + d, + csrfmiddlewaretoken: $("input[name=csrfmiddlewaretoken]").val() + }, + + success:function(response){ + alert("success: " + response); + } + }); } </script> {% endblock %} {% block header %} + <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> @@ -51,7 +79,6 @@ <table class="table table-hover"> <thead> <tr> - <th>Instructor Name</th> <th>Course Name</th> <th>Course Day</th> @@ -75,6 +102,7 @@ </table> </div> + <!-- Page Navigation --> <div class="container"> <div class="Page-Nav" align="center"> diff --git a/workshop_app/templates/workshop_app/registeration_error.html b/workshop_app/templates/workshop_app/registeration_error.html index 7e2c9d8..d460fe6 100644 --- a/workshop_app/templates/workshop_app/registeration_error.html +++ b/workshop_app/templates/workshop_app/registeration_error.html @@ -10,4 +10,4 @@ <h1>Error Occurred While registration</h1> <h3>Please try to <a href="{{ URL_ROOT }}/register"> register again</a> using different username or email and see to it that you fill all the fields.</h3> </div> - {% endblock %}
\ No newline at end of file +{% endblock %}
\ No newline at end of file diff --git a/workshop_app/views.py b/workshop_app/views.py index da277bd..83c59dc 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -145,45 +145,46 @@ def book(request): @login_required def book_workshop(request): - ''' - Function for Updating requested_workshop table - ''' - if request.method == 'POST': - user_position = request.user.profile.position - client_data = request.body.decode("utf-8").split("&") - client_data = client_data[0].split("%2C") - - print(Workshop.objects.filter(workshop_title_id=client_data[2])) - - send_email(request, call_on='Booking', - user_position=user_position) - - instructor_profile = Profile.objects.filter(user=client_data[1]) - workshop_list = Workshop.objects.get( - workshop_instructor=client_data[1] - ) - workshop_recurrence_list = workshop_list.recurrences.between( - datetime(2017, 3, 12, 0, 0, 0), - datetime(2017, 12, 31, 0, 0, 0), - inc=True - ) - for d in workshop_recurrence_list: - if client_data[0][2:] == (d.strftime("%d-%m-%Y")): - rW_obj = RequestedWorkshop() - rW_obj.requested_workshop_instructor = User.objects.get( - id=client_data[1] - ) - rW_obj.requested_workshop_coordinator = request.user - #To be changed - rW_obj.requested_workshop_title = Workshop.objects.all() - - rW_obj.save() - - - - return HttpResponse(instructor_profile) - else: - pass + ''' + Function for Updating requested_workshop table + ''' + if request.method == 'POST': + user_position = request.user.profile.position + client_data = request.body.decode("utf-8").split("&") + client_data = client_data[0].split("%2C") + + send_email(request, call_on='Booking', + user_position=user_position) + + instructor_profile = Profile.objects.filter(user=client_data[1]) + workshop_list = Workshop.objects.get( + workshop_instructor=client_data[1] + ) + workshop_recurrence_list = workshop_list.recurrences.between( + datetime(2017, 3, 12, 0, 0, 0), + datetime(2017, 12, 31, 0, 0, 0), + inc=True + ) + for d in workshop_recurrence_list: + if client_data[0][2:] == (d.strftime("%d-%m-%Y")): + rW_obj = RequestedWorkshop() + + workshop_obj = Workshop.objects.get( + workshop_instructor=client_data[1], + workshop_title_id=client_data[2] + ) + rW_obj.requested_workshop_instructor = workshop_obj.workshop_instructor + rW_obj.requested_workshop_coordinator = request.user + rW_obj.requested_workshop_date = datetime.strptime( + client_data[0][2:], "%d-%m-%Y" + ) + rW_obj.requested_workshop_title = workshop_obj.workshop_title + rW_obj.save() + + return HttpResponse("Thank You, Please check your email for further \ + information.") + else: + return HttpResponse("Some Error Occurred.") |