Merge branch 'develop' of https://github.com/frappe/lms into tests-1

This commit is contained in:
Jannat Patel
2025-12-15 12:13:19 +05:30
69 changed files with 6747 additions and 3348 deletions

View File

@@ -1185,25 +1185,21 @@ def get_notifications(filters):
@frappe.whitelist(allow_guest=True)
def get_lms_setting(field=None):
if not field:
frappe.throw(_("Field name is required"))
frappe.log_error("Field name is missing when accessing LMS Settings {0} {1} {2}").format(
frappe.local.request_ip, frappe.get_request_header("Referer"), frappe.get_request_header("Origin")
)
def get_lms_settings():
allowed_fields = [
"allow_guest_access",
"prevent_skipping_videos",
"contact_us_email",
"contact_us_url",
"livecode_url",
"disable_pwa",
]
if field not in allowed_fields:
frappe.throw(_("You are not allowed to access this field"))
settings = frappe._dict()
for field in allowed_fields:
settings[field] = frappe.get_cached_value("LMS Settings", None, field)
return frappe.get_cached_value("LMS Settings", None, field)
return settings
@frappe.whitelist()

View File

@@ -74,7 +74,11 @@ def get_schedule(course, date, batch=None):
booked_slots = frappe.get_all(
"LMS Certificate Request",
filters={"evaluator": evaluator, "date": date},
filters={
"evaluator": evaluator,
"date": date,
"status": ["!=", "Cancelled"],
},
fields=["start_time", "day"],
)

View File

@@ -28,7 +28,7 @@ class LMSAssignmentSubmission(Document):
)
def validate_url(self):
if self.type == "URL" and not validate_url(self.answer):
if self.type == "URL" and not validate_url(self.answer, True, ["http", "https"]):
frappe.throw(_("Please enter a valid URL."))
def validate_status(self):

View File

@@ -25,7 +25,7 @@ class LMSBatchEnrollment(Document):
return
roles = frappe.get_roles(self.owner)
if not ("Moderator" in roles or "Batch Evaluator" in roles):
if "Moderator" not in roles and "Batch Evaluator" not in roles:
frappe.throw(_("You must be a Moderator or Batch Evaluator to enroll users in a batch."))
def validate_duplicate_members(self):

View File

@@ -17,12 +17,11 @@ class LMSCertificate(Document):
self.name = make_autoname("hash", self.doctype)
def after_insert(self):
if not frappe.in_test:
outgoing_email_account = frappe.get_cached_value(
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
)
if outgoing_email_account or frappe.conf.get("mail_login"):
self.send_mail()
outgoing_email_account = frappe.get_cached_value(
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
)
if outgoing_email_account or frappe.conf.get("mail_login"):
self.send_mail()
def send_mail(self):
subject = _("Congratulations on getting certified!")

View File

@@ -14,15 +14,6 @@ frappe.ui.form.on("LMS Certificate Evaluation", {
},
onload: function (frm) {
frm.set_query("course", function (doc) {
return {
filters: {
enable_certification: true,
grant_certificate_after: "Evaluation",
},
};
});
frm.set_query("member", function (doc) {
return {
filters: {

View File

@@ -76,6 +76,8 @@
"default": "0",
"fieldname": "published",
"fieldtype": "Check",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Published"
},
{
@@ -152,8 +154,6 @@
"fieldname": "status",
"fieldtype": "Select",
"hidden": 1,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Status",
"options": "In Progress\nUnder Review\nApproved",
"read_only": 1
@@ -313,7 +313,7 @@
}
],
"make_attachments_public": 1,
"modified": "2025-10-13 15:08:11.734204",
"modified": "2025-12-11 17:21:05.231761",
"modified_by": "sayali@frappe.io",
"module": "LMS",
"name": "LMS Course",
@@ -336,6 +336,7 @@
"delete": 1,
"email": 1,
"export": 1,
"import": 1,
"print": 1,
"read": 1,
"report": 1,
@@ -348,6 +349,7 @@
"delete": 1,
"email": 1,
"export": 1,
"import": 1,
"print": 1,
"read": 1,
"report": 1,

View File

@@ -12,6 +12,7 @@
"column_break_zdel",
"allow_guest_access",
"prevent_skipping_videos",
"disable_pwa",
"column_break_bjis",
"unsplash_access_key",
"livecode_url",
@@ -438,13 +439,19 @@
"fieldname": "certifications",
"fieldtype": "Check",
"label": "Certifications"
},
{
"default": "0",
"fieldname": "disable_pwa",
"fieldtype": "Check",
"label": "Disable PWA"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2025-12-02 12:21:15.832799",
"modified": "2025-12-10 17:36:15.689695",
"modified_by": "sayali@frappe.io",
"module": "LMS",
"name": "LMS Settings",

View File

@@ -49,7 +49,7 @@ class LMSSettings(Document):
def validate_contact_us_details(self):
if self.contact_us_email and not validate_email_address(self.contact_us_email):
frappe.throw(_("Please enter a valid Contact Us Email."))
if self.contact_us_url and not validate_url(self.contact_us_url, True):
if self.contact_us_url and not validate_url(self.contact_us_url, True, ["http", "https"]):
frappe.throw(_("Please enter a valid Contact Us URL."))

View File

@@ -1774,7 +1774,7 @@ def enroll_in_batch(batch, payment_name=None):
frappe.throw(_("The specified batch does not exist."))
batch_doc = frappe.db.get_value(
"LMS Batch", batch, ["name", "seat_count", "allow_self_enrollment"], as_dict=True
"LMS Batch", batch, ["name", "seat_count", "allow_self_enrollment", "paid_batch"], as_dict=True
)
payment_doc = get_payment_details(payment_name)
validate_enrollment_eligibility(batch_doc, payment_doc)