Shivam Mishra | 823c795 | 2019-05-19 16:01:45 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
| 2 | import erpnext.education.utils as utils |
| 3 | import frappe |
| 4 | |
| 5 | no_cache = 1 |
| 6 | |
| 7 | def get_context(context): |
| 8 | context.education_settings = frappe.get_single("Education Settings") |
| 9 | context.featured_programs = get_featured_programs() |
| 10 | |
| 11 | |
| 12 | def get_featured_programs(): |
| 13 | featured_program_names = frappe.get_all("Program", filters={"is_published": True, "is_featured": True}) |
| 14 | if featured_program_names: |
| 15 | featured_list = [utils.get_program_and_enrollment_status(program['name']) for program in featured_program_names] |
| 16 | return featured_list |
| 17 | else: |
| 18 | return get_all_programs()[:2] |
| 19 | |
| 20 | def get_all_programs(): |
| 21 | program_names = frappe.get_all("Program", filters={"is_published": True}) |
| 22 | if program_names: |
| 23 | program_list = [utils.get_program_and_enrollment_status(program['name']) for program in program_names] |
| 24 | return program_list |