blob: 15ca0b46287b3e810a3004b0d02c41bae48e7696 [file] [log] [blame]
Shivam Mishra823c7952019-05-19 16:01:45 +05301from __future__ import unicode_literals
2import erpnext.education.utils as utils
3import frappe
4
5no_cache = 1
6
7def get_context(context):
8 context.education_settings = frappe.get_single("Education Settings")
Shivam Mishrab7874152019-05-29 15:15:59 +05309 if not context.education_settings.enable_lms:
10 frappe.local.flags.redirect_location = '/'
11 raise frappe.Redirect
Shivam Mishra823c7952019-05-19 16:01:45 +053012 context.featured_programs = get_featured_programs()
13
14
15def get_featured_programs():
16 featured_program_names = frappe.get_all("Program", filters={"is_published": True, "is_featured": True})
17 if featured_program_names:
18 featured_list = [utils.get_program_and_enrollment_status(program['name']) for program in featured_program_names]
19 return featured_list
20 else:
21 return get_all_programs()[:2]
22
23def get_all_programs():
24 program_names = frappe.get_all("Program", filters={"is_published": True})
25 if program_names:
26 program_list = [utils.get_program_and_enrollment_status(program['name']) for program in program_names]
27 return program_list