From dade8a89e3e3f882aa05f974feed1b7248fd6de8 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 22 Aug 2017 12:22:32 +0530 Subject: Change course.js, course_detail.html and views.py - Change form submission for send email in js - Change template and view variable for mail status --- yaksh/static/yaksh/js/course.js | 31 ++++++++++++------------------- yaksh/templates/yaksh/course_detail.html | 4 ++-- yaksh/views.py | 2 +- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 0eeb017..8fb2773 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -38,7 +38,7 @@ $(".reject").change( function(){ $(function() { $('textarea#email_body').froalaEditor({ - heightMin: 100, + heightMin: 200, heightMax: 200 }) }); @@ -46,31 +46,24 @@ $(function() { $("#send_mail").click(function(){ var subject = $("#subject").val(); var body = $('#email_body').val(); - var status; - if (subject == '' || body == ''){ - status = false; - $("#error_msg").html("Please enter mail details"); - $("#dialog").dialog(); - } - else{ - status = true; - } - return status; -}); - -$('#send_mail_form').submit(function(eventObj) { + var status = false; var selected = []; $('#reject input:checked').each(function() { selected.push($(this).attr('value')); }); - if(selected.length > 0) { - return true; + + if (subject == '' || body == ''){ + $("#error_msg").html("Please enter mail details"); + $("#dialog").dialog(); } - else { + else if (selected.length == 0){ $("#error_msg").html("Please select atleast one user"); - $( "#dialog" ).dialog(); - return false; + $("#dialog").dialog(); } + else { + status = true; + } + return status; }); }); diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html index 1f0e894..bcada42 100644 --- a/yaksh/templates/yaksh/course_detail.html +++ b/yaksh/templates/yaksh/course_detail.html @@ -20,7 +20,7 @@
{% endif %} - {% if status == 'mail' %} + {% if state == 'mail' %}
Send Mails to Students

{% if course.get_enrolled %} diff --git a/yaksh/views.py b/yaksh/views.py index b4ab9bb..db45a89 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -759,7 +759,7 @@ def send_mail(request, course_id, user_id=None): ) context = { 'course': course, 'message': message, - 'status': 'mail' + 'state': 'mail' } return my_render_to_response( 'yaksh/course_detail.html', context, context_instance=ci -- cgit