chore: Minor code improvements
- Changed variable name in `get_content` function
- Added proper exceptions for `get_topic` and `get_content` functions in lms
diff --git a/erpnext/public/js/education/lms/components/Article.vue b/erpnext/public/js/education/lms/components/Article.vue
index 4678db2..eab1424 100644
--- a/erpnext/public/js/education/lms/components/Article.vue
+++ b/erpnext/public/js/education/lms/components/Article.vue
@@ -32,7 +32,7 @@
methods: {
getContent() {
return lms.call('get_content', {
- type: this.type,
+ content_type: this.type,
content: this.content
})
}
diff --git a/erpnext/public/js/education/lms/components/Video.vue b/erpnext/public/js/education/lms/components/Video.vue
index 2d791bd..29d973a 100644
--- a/erpnext/public/js/education/lms/components/Video.vue
+++ b/erpnext/public/js/education/lms/components/Video.vue
@@ -55,7 +55,7 @@
methods: {
getContent() {
return lms.call('get_content', {
- type: this.type,
+ content_type: this.type,
content: this.content
})
}
diff --git a/erpnext/www/lms.py b/erpnext/www/lms.py
index 801d766..4416244 100644
--- a/erpnext/www/lms.py
+++ b/erpnext/www/lms.py
@@ -291,13 +291,15 @@
# Functions to get program & course details
@frappe.whitelist(allow_guest=True)
def get_topics(course_name):
- course = frappe.get_doc('Course', course_name)
- topics = course.get_topics()
- return topics
+ try:
+ course = frappe.get_doc('Course', course_name)
+ return course.get_topics()
+ except frappe.DoesNotExistError:
+ frappe.throw(_("Course {0} does not exist.".format(course_name)))
@frappe.whitelist()
-def get_content(type, content):
+def get_content(content_type, content):
try:
- return frappe.get_doc(type, content)
- except:
- return None
\ No newline at end of file
+ return frappe.get_doc(content_type, content)
+ except frappe.DoesNotExistError:
+ frappe.throw(_("{0} {1} does not exist.".format(content_type, content)))
\ No newline at end of file