Skip to content

Commit 643550c

Browse files
feat: Add course team management v2 API for instructor dashboard (#38205)
1 parent 408f947 commit 643550c

7 files changed

Lines changed: 1750 additions & 6 deletions

File tree

lms/djangoapps/instructor/access.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
import logging
1414

15+
from django.contrib.auth import get_user_model
16+
from django.utils.translation import gettext_lazy as _
17+
1518
from common.djangoapps.student.roles import (
1619
CourseBetaTesterRole,
1720
CourseCcxCoachRole,
@@ -21,7 +24,13 @@
2124
CourseStaffRole,
2225
)
2326
from lms.djangoapps.instructor.enrollment import enroll_email, get_email_params
24-
from openedx.core.djangoapps.django_comment_common.models import Role
27+
from openedx.core.djangoapps.django_comment_common.models import (
28+
FORUM_ROLE_ADMINISTRATOR,
29+
FORUM_ROLE_COMMUNITY_TA,
30+
FORUM_ROLE_GROUP_MODERATOR,
31+
FORUM_ROLE_MODERATOR,
32+
Role,
33+
)
2534

2635
log = logging.getLogger(__name__)
2736

@@ -34,6 +43,47 @@
3443
'data_researcher': CourseDataResearcherRole,
3544
}
3645

46+
#: Forum/discussion roles managed through :func:`update_forum_role`.
47+
#: Stored separately from :data:`ROLES` because they use a different
48+
#: model (``Role`` from django_comment_common) and different helpers.
49+
FORUM_ROLES = (
50+
FORUM_ROLE_ADMINISTRATOR,
51+
FORUM_ROLE_MODERATOR,
52+
FORUM_ROLE_GROUP_MODERATOR,
53+
FORUM_ROLE_COMMUNITY_TA,
54+
)
55+
56+
ROLE_DISPLAY_NAMES = {
57+
'instructor': _('Admin'),
58+
'staff': _('Staff'),
59+
'limited_staff': _('Limited Staff'),
60+
'beta': _('Beta Tester'),
61+
'ccx_coach': _('CCX Coach'),
62+
'data_researcher': _('Data Researcher'),
63+
FORUM_ROLE_ADMINISTRATOR: _('Discussion Admin'),
64+
FORUM_ROLE_MODERATOR: _('Discussion Moderator'),
65+
FORUM_ROLE_GROUP_MODERATOR: _('Group Moderator'),
66+
FORUM_ROLE_COMMUNITY_TA: _('Community TA'),
67+
}
68+
69+
70+
def is_forum_role(rolename):
71+
"""Return True if ``rolename`` is a forum/discussion role."""
72+
return rolename in FORUM_ROLES
73+
74+
75+
def list_forum_members(course_id, rolename):
76+
"""
77+
Return a User QuerySet of users holding ``rolename`` forum role for the course.
78+
79+
Returns an empty QuerySet if the role doesn't exist for the course.
80+
"""
81+
try:
82+
role = Role.objects.get(course_id=course_id, name=rolename)
83+
except Role.DoesNotExist:
84+
return get_user_model().objects.none()
85+
return role.users.all()
86+
3787

3888
def list_with_level(course_id, level):
3989
"""

0 commit comments

Comments
 (0)