scmmishra | 6660a67 | 2018-10-08 17:18:11 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
| 2 | import frappe |
| 3 | |
| 4 | |
| 5 | def get_context(context): |
scmmishra | 38c1baf | 2018-10-12 15:22:16 +0530 | [diff] [blame^] | 6 | if frappe.form_dict['course']: |
| 7 | context.current_course = frappe.get_doc("Course", frappe.form_dict["course"]) |
| 8 | context.current_content = frappe.get_doc("Content", frappe.form_dict["content"]) |
| 9 | context.current_program = frappe.form_dict["program"] |
| 10 | context.next_content = get_next_content(context) |
| 11 | |
| 12 | |
| 13 | def get_next_content(context): |
| 14 | if context.current_course: |
| 15 | course_data = [content_item.content for content_item in context.current_course.course_content] |
| 16 | try: |
| 17 | return course_data[course_data.index(context.current_content.name) + 1] |
| 18 | except IndexError: |
| 19 | return None |