feat: Added disable/enable discussion endpoint to swagger

This commit is contained in:
Devasia Joseph
2025-07-10 15:52:25 +05:30
parent 33f239d8fc
commit f330e49aaf
2 changed files with 34 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ from django.urls import reverse
from django.utils.translation import gettext as _
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_GET, require_http_methods
from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiRequest, OpenApiResponse
from edx_django_utils.monitoring import function_trace
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
@@ -1712,6 +1713,37 @@ def group_configurations_detail_handler(request, course_key_string, group_config
)
@extend_schema(
summary="Bulk enable/disable discussions for all units in a course.",
description="Enable or disable discussions for all verticals in the specified course.",
request=OpenApiRequest(
request={
"type": "object",
"properties": {"discussion_enabled": {"type": "boolean"}},
"required": ["discussion_enabled"],
}
),
responses={
200: OpenApiResponse(
response={
"type": "object",
"properties": {"units_updated_and_republished": {"type": "integer"}},
}
),
400: OpenApiResponse(description="Bad request"),
403: OpenApiResponse(description="Permission denied"),
},
methods=["PUT"],
parameters=[
OpenApiParameter(
name="course_key_string",
description="Course key string",
required=True,
type=str,
location=OpenApiParameter.PATH,
)
],
)
@api_view(['PUT'])
@view_auth_classes()
@expect_json

View File

@@ -16,7 +16,8 @@ def cms_api_filter(endpoints):
path.startswith("/api/contentstore/v0/videos") or
path.startswith("/api/contentstore/v0/video_transcripts") or
path.startswith("/api/contentstore/v0/file_assets") or
path.startswith("/api/contentstore/v0/youtube_transcripts")
path.startswith("/api/contentstore/v0/youtube_transcripts") or
path.startswith("/api/courses/") and "bulk_enable_disable_discussions" in path
):
filtered.append((path, path_regex, method, callback))
return filtered