lms.djangoapps.support.rest_api.v1 package#
Submodules#
lms.djangoapps.support.rest_api.v1.urls module#
URL definitions for the course_modes v1 API.
lms.djangoapps.support.rest_api.v1.views module#
API Views for course team management in support app.
- class lms.djangoapps.support.rest_api.v1.views.CourseTeamManageAPIView(*args, **kwargs)#
Bases:
GenericAPIView- Use case:
APIs for viewing and managing a user’s course team roles.
Lists courses where the authenticated user has permission to manage roles.
Displays the given user’s role in each accessible course.
Allows assigning or revoking roles via PUT, limited to courses the user can manage.
- get(request, *args, **kwargs)#
Retrieve a list of courses accessible by the authenticated user
Use Case
GET API to retrieve a list of courses accessible by the authenticated user, along with the specified user’s role (“instructor”, “staff”, or null) in each course.
Endpoint
GET /api/support/v1/manage_course_team/
Query Parameters
At least one of the following parameters is required: - email: User’s email address - username: User’s username - user_id: User’s ID
Returns
List of courses accessible to the authenticated user, each annotated with the specified user’s role in that course. Each course includes organizational information and identifiers.
Example Response
- ```json
- {
- “results”: [
- {
“course_id”: “course-v1:edX+DemoX+2025_T1”, “course_name”: “edX Demonstration Course”, “course_url”: “https://studio.example.com/course/course-v1:edX+DemoX+2025_T1”, “role”: “instructor”, “status”: “active”, “org”: “edX”, “run”: “2025_T1”, “number”: “DemoX”
}, {
“course_id”: “course-v1:MITx+6.00x+2024_Fall”, “course_name”: “Introduction to Computer Science”, “course_url”: “https://studio.example.com/course/course-v1:MITx+6.00x+2024_Fall”, “role”: “staff”, “status”: “archived”, “org”: “MITx”, “run”: “2024_Fall”, “number”: “6.00x”
}
]
}
- get_accessible_courses_for_user(auth_user)#
Return queryset of courses accessible by the authenticated user.
- get_course_role_map_for_user(user)#
Return a mapping of course_id to role for staff/instructor roles of given user.
- get_queryset()#
Main entry to return courses filtered by authenticated user access and requested user roles.
- get_serializer_context()#
Provide extra context to the serializer.
- list(request, *args, **kwargs)#
list of courses for the organization and user.
- openapi = <module 'drf_yasg.openapi' from '/home/docs/checkouts/readthedocs.org/user_builds/edx-platform-docs/envs/latest/lib/python3.12/site-packages/drf_yasg/openapi.py'>#
- pagination_class = None#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- put(request, *args, **kwargs)#
Bulk assign or revoke course team roles for a user across multiple courses.
Endpoint
PUT /api/support/v1/manage_course_team/
Permissions
Admin/Staff users: Can manage roles for any course
Instructor users: Can only manage roles for courses/orgs they have instructor access to
Other users: Access denied
Request Data
- A JSON object containing:
email: User’s email address
- bulk_role_operations: List of role operations, each containing:
course_id: Course key string
role: Role to assign or revoke (“instructor” or “staff”)
action: “assign” or “revoke”
Example Request
“email”: “user1@example.com”, “bulk_role_operations”: [
- {
“course_id”: “course-v1:edX+DemoX+2025_T1”, “role”: “instructor”, “action”: “assign”
}, {
“course_id”: “course-v1:edX+DemoX+2025_T2”, “role”: “staff”, “action”: “revoke”
}
]
}#
Returns
HTTP 200 with results for each operation (success or error details)
HTTP 400 if the request data is invalid
Example Response
“email”: “user1@example.com”, “results”: [
- {
“course_id”: “course-v1:edX+DemoX+2025_T1”, “role”: “instructor”, “action”: “assign”, “status”: “success”
}, {
“course_id”: “course-v1:edX+DemoX+2025_T2”, “role”: “staff”, “action”: “revoke”, “status”: “failed”, “error”: “error_message”
}
]
}#
- serializer_class#
alias of
CourseTeamManageSerializer
- swagger_auto_schema(methods=None, auto_schema=<class 'drf_yasg.utils.unset'>, request_body=None, query_serializer=None, manual_parameters=None, operation_id=None, operation_description=None, operation_summary=None, security=None, deprecated=None, responses=None, field_inspectors=None, filter_inspectors=None, paginator_inspectors=None, tags=None, produces=None, consumes=None, **extra_overrides)#
Decorate a view method to customize the
Operationobject generated from it.method and methods are mutually exclusive and must only be present when decorating a view method that accepts more than one HTTP request method.
The auto_schema and operation_description arguments take precedence over view- or method-level values.
- Parameters:
method (str) – for multi-method views, the http method the options should apply to
methods (list[str]) – for multi-method views, the http methods the options should apply to
auto_schema (drf_yasg.inspectors.SwaggerAutoSchema) – custom class to use for generating the Operation object; this overrides both the class-level
swagger_schemaattribute and theDEFAULT_AUTO_SCHEMA_CLASSsetting, and can be set toNoneto prevent this operation from being generatedrequest_body (drf_yasg.openapi.Schema or drf_yasg.openapi.SchemaRef or rest_framework.serializers.Serializer or type[no_body]) –
custom request body which will be used as the
schemaproperty of aParameterwithin: 'body'.A Schema or SchemaRef is not valid if this request consumes form-data, because
formandbodyparameters are mutually exclusive in anOperation. If you need to set customformparameters, you can use the manual_parameters argument.If a
Serializerclass or instance is given, it will be automatically converted into aSchemaused as abodyParameter, or into a list offormParameters, as appropriate.query_serializer (rest_framework.serializers.Serializer) –
if you use a
Serializerto parse query parameters, you can pass it here and haveParameterobjects be generated automatically from it.If any
Fieldon the serializer cannot be represented as aqueryParameter(e.g. nested Serializers, file fields, …), the schema generation will fail with an error.Schema generation will also fail if the name of any Field on the query_serializer conflicts with parameters generated by
filter_backendsorpaginator.manual_parameters (list[drf_yasg.openapi.Parameter]) –
a list of manual parameters to override the automatically generated ones
Parameters are identified by their (name,in) combination,and any parameters given here will fully override automatically generated parameters if they collide.
It is an error to supply
formparameters when the request does not consume form-data.operation_id (str) – operation ID override; the operation ID must be unique across the whole API
operation_description (str) – operation description override
operation_summary (str) – operation summary string
security (list[dict]) – security requirements override; used to specify which authentication mechanism is required to call this API; an empty list marks the endpoint as unauthenticated (i.e. removes all accepted authentication schemes), and
Nonewill inherit the top-level security requirementsdeprecated (bool) – deprecation status for operation
responses (dict[int or str, (drf_yasg.openapi.Schema or drf_yasg.openapi.SchemaRef or drf_yasg.openapi.Response or str or rest_framework.serializers.Serializer)]) –
a dict of documented manual responses keyed on response status code. If no success (
2xx) response is given, one will automatically be generated from the request body and http method. If any2xxresponse is given the automatic response is suppressed.if a plain string is given as value, a
Responsewith no body and that string as its description will be generatedif
Noneis given as a value, the response is ignored; this is mainly useful for disabling default 2xx responses, i.e.responses={200: None, 302: 'something'}if a
Schema,SchemaRefis given, aResponsewith the schema as its body and an empty description will be generateda
Serializerclass or instance will be converted into aSchemaand treated as abovea
Responseobject will be used as-is; however if itsschemaattribute is aSerializer, it will automatically be converted into aSchema
field_inspectors (list[type[drf_yasg.inspectors.FieldInspector]]) – extra serializer and field inspectors; these will be tried before
ViewInspector.field_inspectorson theinspectors.SwaggerAutoSchemafilter_inspectors (list[type[drf_yasg.inspectors.FilterInspector]]) – extra filter inspectors; these will be tried before
ViewInspector.filter_inspectorson theinspectors.SwaggerAutoSchemapaginator_inspectors (list[type[drf_yasg.inspectors.PaginatorInspector]]) – extra paginator inspectors; these will be tried before
ViewInspector.paginator_inspectorson theinspectors.SwaggerAutoSchematags (list[str]) – tags override
produces (list[str]) – produces override
consumes (list[str]) – consumes override
extra_overrides – extra values that will be saved into the
overridesdict; these values will be available in the handlinginspectors.SwaggerAutoSchemainstance viaself.overrides