refactor: added lms utilities for enrollment and program list

This commit is contained in:
Shivam Mishra
2019-05-29 18:39:52 +05:30
parent 5aa8df840e
commit f927502cc5
4 changed files with 96 additions and 51 deletions

View File

@@ -6,10 +6,4 @@ no_cache = 1
def get_context(context):
context.education_settings = frappe.get_single("Education Settings")
context.all_programs = get_all_programs()
def get_all_programs():
program_names = frappe.get_all("Program", filters={"is_published": True})
if program_names:
program_list = [utils.get_program_and_enrollment_status(program['name']) for program in program_names]
return program_list
context.all_programs = utils.get_portal_programs()

View File

@@ -13,15 +13,4 @@ def get_context(context):
def get_featured_programs():
featured_program_names = frappe.get_all("Program", filters={"is_published": True, "is_featured": True})
if featured_program_names:
featured_list = [utils.get_program_and_enrollment_status(program['name']) for program in featured_program_names]
return featured_list
else:
return get_all_programs()[:2]
def get_all_programs():
program_names = frappe.get_all("Program", filters={"is_published": True})
if program_names:
program_list = [utils.get_program_and_enrollment_status(program['name']) for program in program_names]
return program_list
return utils.get_portal_programs()

View File

@@ -7,6 +7,7 @@ no_cache = 1
def get_context(context):
context.education_settings = frappe.get_single("Education Settings")
context.program = get_program(frappe.form_dict['name'])
context.is_enrolled = utils.get_enrollment_status(program)
def get_program(program_name):
try: