Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions backend/apps/mentorship/api/internal/mutations/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
ASSIGNEE_NOT_FOUND_MSG = "Assignee not found."
ISSUE_NOT_FOUND_MSG = "Issue not found in this module."
MODULE_NOT_FOUND_MSG = "Module not found."
NOT_MENTOR_ASSIGN_MSG = "Only mentors can assign issues."
NOT_MENTOR_CLEAR_DEADLINE_MSG = "Only mentors can clear deadlines."
NOT_MENTOR_SET_DEADLINE_MSG = "Only mentors can set deadlines."
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -147,7 +150,7 @@ def assign_issue_to_user(

mentor = Mentor.objects.filter(nest_user=user).first()
if mentor is None:
raise PermissionDenied(msg="Only mentors can assign issues.")
raise PermissionDenied(NOT_MENTOR_ASSIGN_MSG)
if not module.program.admins.filter(id=mentor.id).exists():
raise PermissionDenied

Expand Down Expand Up @@ -230,7 +233,7 @@ def set_task_deadline(

mentor = Mentor.objects.filter(nest_user=user).first()
if mentor is None:
raise PermissionDenied(msg="Only mentors can set deadlines.")
raise PermissionDenied(NOT_MENTOR_SET_DEADLINE_MSG)
if not module.program.admins.filter(id=mentor.id).exists():
raise PermissionDenied

Expand Down Expand Up @@ -292,7 +295,7 @@ def clear_task_deadline(

mentor = Mentor.objects.filter(nest_user=user).first()
if mentor is None:
raise PermissionDenied(msg="Only mentors can clear deadlines.")
raise PermissionDenied(NOT_MENTOR_CLEAR_DEADLINE_MSG)
if not module.program.admins.filter(id=mentor.id).exists():
raise PermissionDenied

Expand Down
Empty file.
Loading