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": [], "actions": [],
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "format: CLS-{#####}",
"creation": "2022-11-09 16:14:05.876933", "creation": "2022-11-09 16:14:05.876933",
"default_view": "List", "default_view": "List",
"doctype": "DocType", "doctype": "DocType",
@@ -330,11 +329,10 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2024-11-18 16:28:41.336928", "modified": "2025-01-17 10:23:10.580311",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Batch", "name": "LMS Batch",
"naming_rule": "Expression (old style)",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {

View File

@@ -16,6 +16,7 @@ from lms.lms.utils import (
get_quiz_details, get_quiz_details,
get_assignment_details, get_assignment_details,
update_payment_record, update_payment_record,
generate_slug,
) )
from frappe.email.doctype.email_template.email_template import get_email_template 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.validate_evaluation_end_date()
self.add_students_to_live_class() 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): def validate_batch_end_date(self):
if self.end_date < self.start_date: if self.end_date < self.start_date:
frappe.throw(_("Batch end date cannot be before the batch 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): def autoname(self):
if not self.name: if not self.name:
title = self.title self.name = generate_slug(self.title, "LMS Course")
if self.title == "New Course":
title = self.title + str(random.randint(0, 99))
self.name = generate_slug(title, "LMS Course")
def __repr__(self): def __repr__(self):
return f"<Course#{self.name}>" return f"<Course#{self.name}>"