scmmishra | 836a4b5 | 2018-10-08 15:26:05 +0530 | [diff] [blame^] | 1 | from __future__ import unicode_literals |
| 2 | import frappe |
| 3 | |
| 4 | |
| 5 | # Get the classroom's route parameter from the url |
| 6 | url_param = frappe.form_dict["code"] |
| 7 | # Get classroom from classroom_name |
| 8 | current_program = frappe.get_doc("Program", url_param) |
| 9 | |
| 10 | def get_context(context): |
| 11 | context.program = current_program |
| 12 | context.course_list, context.course_data = get_courses() |
| 13 | |
| 14 | def get_courses(): |
| 15 | course_data = {} |
| 16 | course_names = [program.course_name for program in current_program.courses] |
| 17 | program_courses = [frappe.get_doc('Course', name) for name in course_names] |
| 18 | for course_item in program_courses: |
| 19 | course_data[course_item.name] = [content_item.content for content_item in course_item.course_content if content_item.content_type in ('Video', 'Article')] |
| 20 | return course_names, course_data |