From 2d62359adf671d5a75201a2314825039adc7291a Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 15 May 2017 15:03:21 +0530 Subject: Change course.js and course_detail.html - Allow moderator to send emails to students enrollded in a course - Add validations to check email data in course.js --- yaksh/static/yaksh/js/course.js | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'yaksh/static') diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 5b79e68..3e214be 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -35,4 +35,49 @@ $(".reject").change( function(){ }); } }); + +$(function() { + $('textarea#email_body').froalaEditor({ + heightMin: 100, + heightMax: 200 + }) + }); + +var status; +var btn_name; + +$("#send_mail").click(function(){ + btn_name = "send_mail"; + var subject = $("#subject").val(); + var body = $('#email_body').val(); + if (subject == '' || body == ''){ + status = false; + $("#error_msg").html("Please enter email details"); + $("#dialog").dialog(); + } + else{ + status = true; + } +}); + +$('#reject-form').submit(function(eventObj) { + if (btn_name == 'send_mail'){ + if(status == false){ + return false; + } + } + var selected = []; + $('#reject input:checked').each(function() { + selected.push($(this).attr('value')); + }); + if(selected.length > 0){ + return true; + } + else{ + $("#error_msg").html("Please select atleast one user"); + $( "#dialog" ).dialog(); + return false; + } +}); + }); -- cgit From a7c9591eac66eb2751a2706b5686a997d7c236dd Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 12 Jun 2017 18:22:21 +0530 Subject: Add separate form to send emails --- yaksh/static/yaksh/js/course.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/static') diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 3e214be..74ad37c 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -60,7 +60,7 @@ $("#send_mail").click(function(){ } }); -$('#reject-form').submit(function(eventObj) { +$('#send_mail_form').submit(function(eventObj) { if (btn_name == 'send_mail'){ if(status == false){ return false; -- cgit From ca630cd1a3464bc665f06ade7c6e78efa27e93cb Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 17 Aug 2017 10:40:43 +0530 Subject: Change course.js to validate email form details --- yaksh/static/yaksh/js/course.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'yaksh/static') diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 74ad37c..0eeb017 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -43,37 +43,30 @@ $(function() { }) }); -var status; -var btn_name; - $("#send_mail").click(function(){ - btn_name = "send_mail"; var subject = $("#subject").val(); var body = $('#email_body').val(); + var status; if (subject == '' || body == ''){ status = false; - $("#error_msg").html("Please enter email details"); + $("#error_msg").html("Please enter mail details"); $("#dialog").dialog(); } else{ status = true; } + return status; }); $('#send_mail_form').submit(function(eventObj) { - if (btn_name == 'send_mail'){ - if(status == false){ - return false; - } - } var selected = []; $('#reject input:checked').each(function() { selected.push($(this).attr('value')); }); - if(selected.length > 0){ + if(selected.length > 0) { return true; } - else{ + else { $("#error_msg").html("Please select atleast one user"); $( "#dialog" ).dialog(); return false; -- cgit 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 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'yaksh/static') 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; }); }); -- cgit