fix: changed batch naming to be a slug of the title

This commit is contained in:
Jannat Patel
2025-01-17 10:35:26 +05:30
parent 28a687f6bf
commit 9d1211e872
3 changed files with 7 additions and 7 deletions

View File

@@ -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": [
{

View File

@@ -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"))

View File

@@ -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"<Course#{self.name}>"