refactor: added slugs to course and topics to make nice urls

- the slug is autogenerated from the title
- the slug of a topic is unique among all the topics of that course
This commit is contained in:
Anand Chitipothu
2021-04-06 15:49:17 +05:30
parent 6620ecf0c8
commit 175bd19a51
11 changed files with 121 additions and 83 deletions

View File

@@ -16,14 +16,15 @@ def get_context(context):
context.current_batch = context.memberships[0].batch
context.author = context.memberships[0].member
def get_course(name):
course = frappe.db.get_value('LMS Course', name,
['name', 'title', 'description'], as_dict=1)
def get_course(slug):
course = frappe.db.get_value('LMS Course', {"slug": slug},
['name', 'slug', 'title', 'description'], as_dict=1)
course['topics'] = frappe.db.get_all('LMS Topic',
filters={
'course': name
'course': course['name']
},
fields=['name', 'title', 'preview'],
fields=['name', 'slug', 'title', 'preview'],
order_by='creation'
)
return course