fix: batch switch with query parameters
This commit is contained in:
@@ -5,14 +5,18 @@ def get_common_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
course_name = frappe.form_dict["course"]
|
||||
try:
|
||||
batch_name = frappe.form_dict["batch"]
|
||||
except KeyError:
|
||||
batch_name = None
|
||||
|
||||
course = Course.find(course_name)
|
||||
if not course:
|
||||
context.template = "www/404.html"
|
||||
return
|
||||
context.course = course
|
||||
|
||||
membership = course.get_current_membership(frappe.session.user)
|
||||
|
||||
membership = course.get_membership(frappe.session.user, batch_name)
|
||||
if membership:
|
||||
context.membership = membership
|
||||
batch = course.get_batch(membership.batch)
|
||||
@@ -22,14 +26,13 @@ def get_common_context(context):
|
||||
|
||||
context.members = course.get_mentors(membership.batch) + course.get_students(membership.batch)
|
||||
context.member_count = len(context.members)
|
||||
|
||||
|
||||
context.course = course
|
||||
context.course.query_parameter = "?batch=" + batch.name if batch else ""
|
||||
print(context.membership)
|
||||
context.livecode_url = get_livecode_url()
|
||||
|
||||
def get_livecode_url():
|
||||
return frappe.db.get_single_value("LMS Settings", "livecode_url")
|
||||
|
||||
def redirect_to_lesson(course, index_="1.1"):
|
||||
frappe.local.flags.redirect_location = course.get_learn_url(index_)
|
||||
frappe.local.flags.redirect_location = course.get_learn_url(index_) + course.query_parameter
|
||||
raise frappe.Redirect
|
||||
|
||||
Reference in New Issue
Block a user