From 199cbcf33f70547a6ff55e49962773ec71d6b23c Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 3 Nov 2022 11:20:58 +0530 Subject: [PATCH] fix: messages if access lacking --- lms/www/batch/learn.py | 6 ++++-- lms/www/courses/course.py | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lms/www/batch/learn.py b/lms/www/batch/learn.py index 2b060f9c..7902c945 100644 --- a/lms/www/batch/learn.py +++ b/lms/www/batch/learn.py @@ -1,7 +1,9 @@ import frappe from lms.www.utils import get_common_context, redirect_to_lesson -from lms.lms.utils import get_lesson_url, has_course_moderator_role, is_instructor, redirect_to_courses_list +from lms.lms.utils import get_lesson_url, has_course_moderator_role, is_instructor from frappe.utils import cstr, flt +from frappe import _ + def get_context(context): get_common_context(context) @@ -28,7 +30,7 @@ def get_context(context): if frappe.form_dict.get("edit"): if not instructor and not has_course_moderator_role(): - redirect_to_courses_list() + raise frappe.PermissionError(_("You do not have permission to access this page.")) context.lesson.edit_mode = True else: neighbours = get_neighbours(lesson_number, context.lessons) diff --git a/lms/www/courses/course.py b/lms/www/courses/course.py index 180f74c1..d52026a4 100644 --- a/lms/www/courses/course.py +++ b/lms/www/courses/course.py @@ -34,12 +34,11 @@ def set_course_context(context, course_name): if frappe.form_dict.get("edit"): if not is_instructor(course.name) and not has_course_moderator_role(): - redirect_to_courses_list() + raise frappe.PermissionError(_("You do not have permission to access this page.")) course.edit_mode = True if course is None: - frappe.local.flags.redirect_location = "/courses" - raise frappe.Redirect + redirect_to_courses_list() related_courses = frappe.get_all("Related Courses", {"parent": course.name}, ["course"]) for csr in related_courses: