Skip to content

Commit

Permalink
Merge pull request #1255 from pateljannat/batch-url
Browse files Browse the repository at this point in the history
refactor: changed batch naming to be a slug of the title
  • Loading branch information
pateljannat authored Jan 17, 2025
2 parents 215ae94 + 9d1211e commit 34685eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lms/lms/doctype/lms_batch/lms_batch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
{
Expand Down
5 changes: 5 additions & 0 deletions lms/lms/doctype/lms_batch/lms_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
get_quiz_details,
get_assignment_details,
update_payment_record,
generate_slug,
)
from frappe.email.doctype.email_template.email_template import get_email_template

Expand All @@ -36,6 +37,10 @@ def validate(self):
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"))
Expand Down
5 changes: 1 addition & 4 deletions lms/lms/doctype/lms_course/lms_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ def send_email_to_interested_users(self):

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}>"
Expand Down

0 comments on commit 34685eb

Please sign in to comment.