diff --git a/lms/lms/doctype/lms_batch/lms_batch.py b/lms/lms/doctype/lms_batch/lms_batch.py index 3c6e034f..cff87d28 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.py +++ b/lms/lms/doctype/lms_batch/lms_batch.py @@ -245,6 +245,10 @@ def fetch_lessons(courses): @frappe.whitelist() def add_course(course, parent, name=None, evaluator=None): frappe.only_for("Moderator") + + if frappe.db.exists("Batch Course", {"course": course, "parent": parent}): + frappe.throw(_("Course already added to the batch.")) + if name: doc = frappe.get_doc("Batch Course", name) else: diff --git a/lms/patches.txt b/lms/patches.txt index 19f9a649..ef457315 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -68,4 +68,5 @@ lms.patches.v1_0.rename_lms_batch_membership_doctype lms.patches.v1_0.rename_lms_class_to_lms_batch lms.patches.v1_0.rename_classes_in_navbar lms.patches.v1_0.publish_batches -lms.patches.v1_0.publish_certificates \ No newline at end of file +lms.patches.v1_0.publish_certificates +lms.patches.v1_0.change_naming_for_batch_course #14-09-2023 \ No newline at end of file diff --git a/lms/patches/v1_0/change_naming_for_batch_course.py b/lms/patches/v1_0/change_naming_for_batch_course.py new file mode 100644 index 00000000..7a93720c --- /dev/null +++ b/lms/patches/v1_0/change_naming_for_batch_course.py @@ -0,0 +1,6 @@ +import frappe + + +def execute(): + frappe.db.create_sequence("Batch Course", check_not_exists=True) + frappe.db.set_next_sequence_val("Batch Course", 500, is_val_used=False) diff --git a/lms/www/batches/batch_details.js b/lms/www/batches/batch_details.js index 19d718bc..92070ece 100644 --- a/lms/www/batches/batch_details.js +++ b/lms/www/batches/batch_details.js @@ -31,6 +31,7 @@ const show_course_modal = (e) => { reqd: 1, only_select: 1, default: course || "", + read_only: course ? 1 : 0, }, { fieldtype: "Link",