Helper Functions for VueJS
This commit is contained in:
parent
84297fa349
commit
9c642ace52
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
import erpnext.education.utils as utils
|
||||
|
||||
# Functions to get homepage details
|
||||
@frappe.whitelist()
|
||||
def get_portal_details():
|
||||
settings = frappe.get_doc("Education Settings")
|
||||
@ -18,6 +19,7 @@ def get_featured_programs():
|
||||
else:
|
||||
return None
|
||||
|
||||
# Functions to get program & course details
|
||||
@frappe.whitelist()
|
||||
def get_program_details(program_name):
|
||||
try:
|
||||
@ -25,3 +27,37 @@ def get_program_details(program_name):
|
||||
return program
|
||||
except:
|
||||
return None
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_courses(program_name):
|
||||
program = frappe.get_doc('Program', program_name)
|
||||
courses = program.get_course_list()
|
||||
return courses
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_starting_content(course_name):
|
||||
course = frappe.get_doc('Course', course_name)
|
||||
content = course.course_content[0].content
|
||||
content_type = course.course_content[0].content_type
|
||||
return dict(content=content, content_type=content_type)
|
||||
|
||||
|
||||
# Functions to get content details
|
||||
@frappe.whitelist()
|
||||
def get_content(content_name, content_type):
|
||||
try:
|
||||
content = frappe.get_doc(content_type, content_name)
|
||||
return content
|
||||
except:
|
||||
frappe.throw("{0} with name {1} does not exist".format(content_type, content_name))
|
||||
return None
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_next_content(content, content_type, course):
|
||||
course_doc = frappe.get_doc("Course", course)
|
||||
content_list = [{'content_type':item.content_type, 'content':item.content} for item in course_doc.get_all_children()]
|
||||
current_index = content_list.index({'content': content, 'content_type': content_type})
|
||||
try:
|
||||
return content_list[current_index + 1]
|
||||
except IndexError:
|
||||
return None
|
Loading…
x
Reference in New Issue
Block a user