diff --git a/lms/lms/doctype/batch_student/batch_student.py b/lms/lms/doctype/batch_student/batch_student.py index d3168f71..733b989e 100644 --- a/lms/lms/doctype/batch_student/batch_student.py +++ b/lms/lms/doctype/batch_student/batch_student.py @@ -11,6 +11,10 @@ class BatchStudent(Document): @frappe.whitelist() def enroll_batch(batch_name): + if frappe.db.exists( + "Batch Student", {"student": frappe.session.user, "parent": batch_name} + ): + frappe.throw("You are already enrolled in this batch") enrollment = frappe.new_doc("Batch Student") enrollment.student = frappe.session.user enrollment.parent = batch_name