fix: skip self enrollment check if paid batch

This commit is contained in:
Jannat Patel
2025-12-24 11:18:54 +05:30
parent 8619712d20
commit 987b655976

View File

@@ -46,8 +46,12 @@ class LMSBatchEnrollment(Document):
frappe.throw(_("Payment is required to enroll in this batch."))
def validate_self_enrollment(self):
allow_self_enrollment = frappe.db.get_value("LMS Batch", self.batch, "allow_self_enrollment")
if not allow_self_enrollment and not self.is_admin():
batch_details = frappe.db.get_value(
"LMS Batch", self.batch, ["allow_self_enrollment", "paid_batch"], as_dict=True
)
if batch_details.paid_batch:
return
if not batch_details.allow_self_enrollment and not self.is_admin():
frappe.throw(_("Enrollment in this batch is restricted. Please contact the Administrator."))
def is_admin(self):