fix: messages if access lacking

This commit is contained in:
Jannat Patel
2022-11-03 11:20:58 +05:30
parent 1f4c7fcb0f
commit 199cbcf33f
2 changed files with 6 additions and 5 deletions

View File

@@ -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)

View File

@@ -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: