fix: batch switch with query parameters
This commit is contained in:
@@ -14,9 +14,11 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-between align-items-end">
|
||||
<h2 id="course-title" data-course="{{course.name}}">{{course.title}}</h2>
|
||||
{% if not course.disable_self_learning and not course.is_mentor(frappe.session.user) %}
|
||||
<div>
|
||||
<button class="btn btn-primary join-batch" data-course="{{ course.name | urlencode }}"> Join the Course</button>
|
||||
<button class="btn btn-primary join-batch" data-course="{{ course.name | urlencode }}"> Start Learning </button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="course-short-intro">{{ course.short_introduction }}</div>
|
||||
</div>
|
||||
|
||||
@@ -75,21 +75,4 @@ frappe.ready(() => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$(".manage-batch").click((e) => {
|
||||
e.preventDefault();
|
||||
var batch = decodeURIComponent($(e.currentTarget).attr("data-batch"));
|
||||
var course = decodeURIComponent($(e.currentTarget).attr("data-course"));
|
||||
frappe.call({
|
||||
method: "community.lms.doctype.lms_batch_membership.lms_batch_membership.update_current_membership",
|
||||
args: {
|
||||
batch: batch,
|
||||
course: course,
|
||||
member: frappe.session.user
|
||||
},
|
||||
callback: (data) => {
|
||||
window.location.href = `/courses/${course}/home`;
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,9 +16,8 @@ def get_context(context):
|
||||
raise frappe.Redirect
|
||||
|
||||
context.course = course
|
||||
|
||||
batch = course.get_student_batch(frappe.session.user)
|
||||
if batch:
|
||||
frappe.local.flags.redirect_location = f"/courses/{course.name}/learn"
|
||||
raise frappe.Redirect
|
||||
|
||||
if not course.is_mentor(frappe.session.user):
|
||||
batch = course.get_membership(frappe.session.user)
|
||||
if batch:
|
||||
frappe.local.flags.redirect_location = f"/courses/{course.name}/learn"
|
||||
raise frappe.Redirect
|
||||
|
||||
Reference in New Issue
Block a user