fix: messages if access lacking
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from lms.www.utils import get_common_context, redirect_to_lesson
|
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.utils import cstr, flt
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
get_common_context(context)
|
get_common_context(context)
|
||||||
@@ -28,7 +30,7 @@ def get_context(context):
|
|||||||
|
|
||||||
if frappe.form_dict.get("edit"):
|
if frappe.form_dict.get("edit"):
|
||||||
if not instructor and not has_course_moderator_role():
|
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
|
context.lesson.edit_mode = True
|
||||||
else:
|
else:
|
||||||
neighbours = get_neighbours(lesson_number, context.lessons)
|
neighbours = get_neighbours(lesson_number, context.lessons)
|
||||||
|
|||||||
@@ -34,12 +34,11 @@ def set_course_context(context, course_name):
|
|||||||
|
|
||||||
if frappe.form_dict.get("edit"):
|
if frappe.form_dict.get("edit"):
|
||||||
if not is_instructor(course.name) and not has_course_moderator_role():
|
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
|
course.edit_mode = True
|
||||||
|
|
||||||
if course is None:
|
if course is None:
|
||||||
frappe.local.flags.redirect_location = "/courses"
|
redirect_to_courses_list()
|
||||||
raise frappe.Redirect
|
|
||||||
|
|
||||||
related_courses = frappe.get_all("Related Courses", {"parent": course.name}, ["course"])
|
related_courses = frappe.get_all("Related Courses", {"parent": course.name}, ["course"])
|
||||||
for csr in related_courses:
|
for csr in related_courses:
|
||||||
|
|||||||
Reference in New Issue
Block a user