fix: progress view

This commit is contained in:
Jannat Patel
2023-06-01 14:29:15 +05:30
parent 961f8c1627
commit fe80ef9b85
7 changed files with 61 additions and 36 deletions

View File

@@ -1,11 +1,14 @@
import frappe
from frappe import _
from lms.lms.utils import has_course_moderator_role
def get_context(context):
context.no_cache = 1
context.is_moderator = has_course_moderator_role()
submission = frappe.form_dict["submission"]
assignment = frappe.form_dict["assignment"]
context.assignment = frappe.db.get_value(
"LMS Assignment", assignment, ["title", "name", "type", "question"], as_dict=1
)
@@ -16,9 +19,11 @@ def get_context(context):
context.submission = frappe.db.get_value(
"LMS Assignment Submission",
submission,
["name", "assignment_attachment", "comments", "status"],
["name", "assignment_attachment", "comments", "status", "member", "member_name"],
as_dict=True,
)
if not context.is_moderator and frappe.session.user != context.submission.member:
raise frappe.PermissionError(_("You don't have permission to access this page."))
if not context.assignment or not context.submission:
raise frappe.PermissionError(_("Invalid Submission URL"))