From 3b578d750a1f02dc0aa0250024d607a6c4ec7a56 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Thu, 22 Apr 2021 14:43:04 +0530 Subject: [PATCH] fix: validations for new batch form --- community/hooks.py | 10 +-- .../add_a_new_batch/add_a_new_batch.js | 20 ++++- .../add_a_new_batch/add_a_new_batch.json | 12 +-- community/www/courses/course.html | 82 ++----------------- 4 files changed, 39 insertions(+), 85 deletions(-) diff --git a/community/hooks.py b/community/hooks.py index 1f06cd18..cc1f7131 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -98,11 +98,11 @@ doc_events = { # Scheduled Tasks # --------------- -scheduler_events = { - "daily": [ - "erpnext.stock.reorder_item.reorder_item" - ] -} +#scheduler_events = { +# "daily": [ +# "erpnext.stock.reorder_item.reorder_item" +# ] +#} # Testing # ------- diff --git a/community/lms/web_form/add_a_new_batch/add_a_new_batch.js b/community/lms/web_form/add_a_new_batch/add_a_new_batch.js index 808b6bc0..6cabe776 100644 --- a/community/lms/web_form/add_a_new_batch/add_a_new_batch.js +++ b/community/lms/web_form/add_a_new_batch/add_a_new_batch.js @@ -1,4 +1,4 @@ -frappe.ready(function() { +frappe.ready(function () { frappe.web_form.after_save = () => { let data = frappe.web_form.get_values(); frappe.call({ @@ -14,4 +14,22 @@ frappe.ready(function() { } }) } + + frappe.web_form.validate = () => { + let data = frappe.web_form.get_values(); + if (!frappe.datetime.validate(data.start_time) || !frappe.datetime.validate(data.end_time)) { + frappe.msgprint(__('Invalid Start or End Time.')); + return false; + } + if (data.start_time > data.end_time) { + frappe.msgprint(__('Start Time should be less than End Time.')); + return false; + } + console.log(data.start_date, date.nowdate()) + if (data.start_date < date.nowdate()) { + frappe.msgprint(__('Start date cannot be a past date.')) + return false; + } + return true; + }; }) \ No newline at end of file diff --git a/community/lms/web_form/add_a_new_batch/add_a_new_batch.json b/community/lms/web_form/add_a_new_batch/add_a_new_batch.json index 8f027787..c0f49820 100644 --- a/community/lms/web_form/add_a_new_batch/add_a_new_batch.json +++ b/community/lms/web_form/add_a_new_batch/add_a_new_batch.json @@ -18,7 +18,7 @@ "is_standard": 1, "login_required": 1, "max_attachment_size": 0, - "modified": "2021-04-21 10:22:38.461088", + "modified": "2021-04-21 16:39:09.457653", "modified_by": "Administrator", "module": "LMS", "name": "add-a-new-batch", @@ -56,7 +56,7 @@ "max_length": 0, "max_value": 0, "read_only": 0, - "reqd": 0, + "reqd": 1, "show_in_filter": 0 }, { @@ -68,7 +68,7 @@ "max_length": 0, "max_value": 0, "read_only": 0, - "reqd": 0, + "reqd": 1, "show_in_filter": 0 }, { @@ -91,7 +91,7 @@ "max_length": 0, "max_value": 0, "read_only": 0, - "reqd": 0, + "reqd": 1, "show_in_filter": 0 }, { @@ -105,7 +105,7 @@ "max_value": 0, "options": "", "read_only": 0, - "reqd": 0, + "reqd": 1, "show_in_filter": 0 }, { @@ -117,7 +117,7 @@ "max_length": 0, "max_value": 0, "read_only": 0, - "reqd": 0, + "reqd": 1, "show_in_filter": 0 } ] diff --git a/community/www/courses/course.html b/community/www/courses/course.html index a95bb8ec..a2a09f9b 100644 --- a/community/www/courses/course.html +++ b/community/www/courses/course.html @@ -84,17 +84,15 @@ {% block content %}
+ -
Enrolled
+
-

{{ course.title }}

{% if course.short_introduction %} {{course.short_introduction}} {% endif %}
@@ -107,6 +105,7 @@
{% endif %}
+ {% if is_mentor %}

Your Batches

{% if mentor_batches %} @@ -156,6 +155,7 @@ {% endif %} {% endif %} + {% if not is_mentor and upcoming_batches %}

Upcoming Batches

@@ -192,12 +192,14 @@
{% endif %} + {% if course.description %}

About the Course

{{frappe.utils.md_to_html(course.description)}}
{% endif %} +

Instructor

@@ -210,6 +212,7 @@
+ {% if mentors %}

Mentors

@@ -233,6 +236,7 @@
{% endif %} + {% if not is_mentor %}
Interested to mentor this course? Cancel your Application.
{% endif %} + {% if course.topics %}

Topics

@@ -259,74 +264,5 @@
{% endif %} -
{% endblock %} \ No newline at end of file