Merge pull request #17911 from scmmishra/lms-redirect-fixes

fix: redirect to lms home if query params not set
This commit is contained in:
Shivam Mishra 2019-06-12 16:05:34 +05:30 committed by GitHub
commit 5e62142ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 7 deletions

View File

@ -5,9 +5,16 @@ import frappe
no_cache = 1
def get_context(context):
try:
program = frappe.form_dict['program']
course_name = frappe.form_dict['name']
except KeyError:
frappe.local.flags.redirect_location = '/lms'
raise frappe.Redirect
context.education_settings = frappe.get_single("Education Settings")
course = frappe.get_doc('Course', frappe.form_dict['name'])
context.program = frappe.form_dict['program']
course = frappe.get_doc('Course', course_name)
context.program = program
context.course = course
context.topics = course.get_topics()

View File

@ -6,10 +6,16 @@ from frappe import _
no_cache = 1
def get_context(context):
try:
program = frappe.form_dict['program']
except KeyError:
frappe.local.flags.redirect_location = '/lms'
raise frappe.Redirect
context.education_settings = frappe.get_single("Education Settings")
context.program = get_program(frappe.form_dict['program'])
context.program = get_program(program)
context.courses = [frappe.get_doc("Course", course.course) for course in context.program.courses]
context.has_access = utils.allowed_program_access(frappe.form_dict['program'])
context.has_access = utils.allowed_program_access(program)
context.progress = get_course_progress(context.courses, context.program)
def get_program(program_name):

View File

@ -5,9 +5,13 @@ import frappe
no_cache = 1
def get_context(context):
course = frappe.form_dict['course']
program = frappe.form_dict['program']
topic = frappe.form_dict['topic']
try:
course = frappe.form_dict['course']
program = frappe.form_dict['program']
topic = frappe.form_dict['topic']
except KeyError:
frappe.local.flags.redirect_location = '/lms'
raise frappe.Redirect
context.program = program
context.course = course