|
28 | 28 | from lms.djangoapps.course_api.blocks.api import get_blocks
|
29 | 29 | from lms.djangoapps.course_goals.models import UserActivity
|
30 | 30 | from lms.djangoapps.discussion.rate_limit import is_content_creation_rate_limited
|
31 |
| -from lms.djangoapps.discussion.rest_api.permissions import IsAllowedToBulkDelete |
32 | 31 | from lms.djangoapps.discussion.rest_api.tasks import delete_course_post_for_user
|
33 | 32 | from lms.djangoapps.discussion.toggles import ONLY_VERIFIED_USERS_CAN_POST
|
34 | 33 | from lms.djangoapps.discussion.django_comment_client import settings as cc_settings
|
@@ -1549,31 +1548,34 @@ def post(self, request, course_id, rolename):
|
1549 | 1548 |
|
1550 | 1549 | class BulkDeleteUserPosts(DeveloperErrorViewMixin, APIView):
|
1551 | 1550 | """
|
1552 |
| - **Use Cases** |
1553 |
| - A privileged user that can delete all posts and comments made by a user. |
1554 |
| - It returns expected number of comments and threads that will be deleted |
1555 |
| -
|
1556 |
| - **Example Requests**: |
1557 |
| - POST /api/discussion/v1/bulk_delete_user_posts/{course_id} |
1558 |
| - Query Parameters: |
1559 |
| - username: The username of the user whose posts are to be deleted |
1560 |
| - course_id: Course id for which posts are to be removed |
1561 |
| - execute: If True, runs deletion task |
1562 |
| - course_or_org: If 'course', deletes posts in the course, if 'org', deletes posts in all courses of the org |
1563 |
| -
|
1564 |
| - **Example Response**: |
1565 |
| - Empty string |
| 1551 | + Bulk-delete posts for a forum user (generally in reponse to spam). |
1566 | 1552 | """
|
1567 | 1553 |
|
1568 | 1554 | authentication_classes = (
|
1569 | 1555 | JwtAuthentication, BearerAuthentication, SessionAuthentication,
|
1570 | 1556 | )
|
1571 |
| - permission_classes = (permissions.IsAuthenticated, IsAllowedToBulkDelete) |
| 1557 | + permission_classes = (permissions.IsAuthenticated, permissions.IsAdminUser) |
1572 | 1558 |
|
1573 | 1559 | def post(self, request, course_id):
|
1574 | 1560 | """
|
1575 |
| - Implements the delete user posts endpoint. |
1576 |
| - TODO: Add support for MySQLBackend as well |
| 1561 | + Delete all posts and comments made by a user across a course or a course's entire org. |
| 1562 | + It returns expected number of comments and threads that will be deleted. |
| 1563 | + This only works on legacy MongoDB-backed forums, not MySQL backed forums. |
| 1564 | +
|
| 1565 | + POST /api/discussion/v1/bulk_delete_user_posts/{course_id} |
| 1566 | +
|
| 1567 | + Query Parameters: |
| 1568 | + * username: The username of the user whose posts are to be deleted. |
| 1569 | + * course_or_org: See below. |
| 1570 | + * course_id: If course_or_org=="course", then a user's posts in this org will be removed. |
| 1571 | + If course_or_org=="org", then a user's posts will be removed across the |
| 1572 | + whole org containing this course. |
| 1573 | + * execute: If True, runs deletion task; if False, just return # of comments and threads |
| 1574 | + that would be deleted. |
| 1575 | +
|
| 1576 | + Notes: This API is a work-in-progress. We are experimentally releasing in Ulmo to superusers only. |
| 1577 | + In Verawood, we plan to allow course staff and forum moderators to bulk-delete posts for |
| 1578 | + contexts which they have access to. See https://github.com/openedx/edx-platform/issues/37402 for details. |
1577 | 1579 | """
|
1578 | 1580 | username = request.GET.get("username", None)
|
1579 | 1581 | execute_task = request.GET.get("execute", "false").lower() == "true"
|
|
0 commit comments