From 9d1211e872e46afca861db63b2156298b792124c Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 17 Jan 2025 10:35:26 +0530 Subject: [PATCH] fix: changed batch naming to be a slug of the title --- lms/lms/doctype/lms_batch/lms_batch.json | 4 +--- lms/lms/doctype/lms_batch/lms_batch.py | 5 +++++ lms/lms/doctype/lms_course/lms_course.py | 5 +---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index 515aa8ce..d9f52d56 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -2,7 +2,6 @@ "actions": [], "allow_import": 1, "allow_rename": 1, - "autoname": "format: CLS-{#####}", "creation": "2022-11-09 16:14:05.876933", "default_view": "List", "doctype": "DocType", @@ -330,11 +329,10 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-11-18 16:28:41.336928", + "modified": "2025-01-17 10:23:10.580311", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", - "naming_rule": "Expression (old style)", "owner": "Administrator", "permissions": [ { diff --git a/lms/lms/doctype/lms_batch/lms_batch.py b/lms/lms/doctype/lms_batch/lms_batch.py index af034ec3..c26594a2 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.py +++ b/lms/lms/doctype/lms_batch/lms_batch.py @@ -16,6 +16,7 @@ from lms.lms.utils import ( get_quiz_details, get_assignment_details, update_payment_record, + generate_slug, ) from frappe.email.doctype.email_template.email_template import get_email_template @@ -36,6 +37,10 @@ class LMSBatch(Document): self.validate_evaluation_end_date() self.add_students_to_live_class() + def autoname(self): + if not self.name: + self.name = generate_slug(self.title, "LMS Batch") + def validate_batch_end_date(self): if self.end_date < self.start_date: frappe.throw(_("Batch end date cannot be before the batch start date")) diff --git a/lms/lms/doctype/lms_course/lms_course.py b/lms/lms/doctype/lms_course/lms_course.py index c66e456d..1870130a 100644 --- a/lms/lms/doctype/lms_course/lms_course.py +++ b/lms/lms/doctype/lms_course/lms_course.py @@ -93,10 +93,7 @@ class LMSCourse(Document): def autoname(self): if not self.name: - title = self.title - if self.title == "New Course": - title = self.title + str(random.randint(0, 99)) - self.name = generate_slug(title, "LMS Course") + self.name = generate_slug(self.title, "LMS Course") def __repr__(self): return f""