From 9c1506d3c8773dd447f2bffec0941653109fea80 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 15 Jun 2021 18:40:14 +0530 Subject: [PATCH] fix: minor issues --- .../doctype/lms_batch_membership/lms_batch_membership.py | 2 +- community/lms/doctype/lms_course/lms_course.py | 6 +++--- community/lms/widgets/BatchTabs.html | 3 ++- community/www/batch/join.html | 3 ++- community/www/batch/utils.py | 2 +- community/www/courses/course.js | 3 ++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/community/lms/doctype/lms_batch_membership/lms_batch_membership.py b/community/lms/doctype/lms_batch_membership/lms_batch_membership.py index f7a39b74..e64cbeed 100644 --- a/community/lms/doctype/lms_batch_membership/lms_batch_membership.py +++ b/community/lms/doctype/lms_batch_membership/lms_batch_membership.py @@ -55,7 +55,7 @@ def create_membership(batch, member=None, member_type="Student", role="Member"): return "OK" @frappe.whitelist() -def update_current_membership(batch, course, member=frappe.session.user): +def update_current_membership(batch, course, member): all_memberships = frappe.get_all("LMS Batch Membership", {"member": member, "course": course}) for membership in all_memberships: frappe.db.set_value("LMS Batch Membership", membership.name, "is_current", 0) diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index e4a35ad2..c6dce996 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -192,16 +192,16 @@ class LMSCourse(Document): return return f"/courses/{self.name}/learn/{lesson_number}" - def get_current_batch(self, member=frappe.session.user): + def get_current_batch(self, member): current_membership = frappe.get_all("LMS Batch Membership", {"member": member, "course": self.name, "is_current": 1}, pluck="batch") - print(current_membership, member, self.name) + print(current_membership, member, self.name, frappe.session.user) if len(current_membership): return current_membership[0] print(frappe.db.get_value("LMS Batch Membership", {"member": member, "course": self.name}, "batch")) return frappe.db.get_value("LMS Batch Membership", {"member": member, "course": self.name}, "batch") def get_all_memberships(self, member=frappe.session.user): - print(member) + print(member, frappe.session.user) all_memberships = frappe.get_all("LMS Batch Membership", {"member": member, "course": self.name}, ["batch", "is_current"]) print(all_memberships) for membership in all_memberships: diff --git a/community/lms/widgets/BatchTabs.html b/community/lms/widgets/BatchTabs.html index 5a3b8a0f..a6778594 100644 --- a/community/lms/widgets/BatchTabs.html +++ b/community/lms/widgets/BatchTabs.html @@ -65,7 +65,8 @@ method: "community.lms.doctype.lms_batch_membership.lms_batch_membership.update_current_membership", args: { batch: batch, - course: course + course: course, + member: frappe.session.user }, callback: (data) => { window.location.reload(); diff --git a/community/www/batch/join.html b/community/www/batch/join.html index 0b2ba3ac..0585d314 100644 --- a/community/www/batch/join.html +++ b/community/www/batch/join.html @@ -72,7 +72,8 @@ frappe.ready(() => { method: "community.lms.doctype.lms_batch_membership.lms_batch_membership.update_current_membership", args: { "batch": "{{ batch.name }}", - "course": "{{ batch.course}}" + "course": "{{ batch.course}}", + "member": frappe.session.user }, callback: (data) => { window.location.href = "/courses/{{ batch.course }}/home" diff --git a/community/www/batch/utils.py b/community/www/batch/utils.py index b99fb129..cd7e6b50 100644 --- a/community/www/batch/utils.py +++ b/community/www/batch/utils.py @@ -11,7 +11,7 @@ def get_common_context(context): context.template = "www/404.html" return - batch_name = course.get_current_batch() + batch_name = course.get_current_batch(frappe.session.user) batch = course.get_batch(batch_name) context.batch = batch if batch_name: diff --git a/community/www/courses/course.js b/community/www/courses/course.js index 58928149..142318e3 100644 --- a/community/www/courses/course.js +++ b/community/www/courses/course.js @@ -82,7 +82,8 @@ frappe.ready(() => { method: "community.lms.doctype.lms_batch_membership.lms_batch_membership.update_current_membership", args: { batch: batch, - course: course + course: course, + member: frappe.session.user }, callback: (data) => { window.location.href = `/courses/${course}/home`;