feat(discussion): Implement discussion moderation features#110
Draft
mraman-2U wants to merge 9 commits intorelease-ulmofrom
Draft
feat(discussion): Implement discussion moderation features#110mraman-2U wants to merge 9 commits intorelease-ulmofrom
mraman-2U wants to merge 9 commits intorelease-ulmofrom
Conversation
92504d2 to
182c1b6
Compare
…s error - Reorder installation steps to install setuptools before edx-repo-tools - Fix typo: 'setuptool' -> 'setuptools' in step name - Add pip upgrade for good measure - Resolves ModuleNotFoundError: No module named 'pkg_resources' in Python 3.12
…resources error" This reverts commit 76ddc4c.
This reverts commit 9647170.
jcapphelix
requested changes
Feb 16, 2026
jcapphelix
left a comment
There was a problem hiding this comment.
Some minor changes @mraman-2U
Also, there will be other set of PRs for edx-internal repos for new added variables ?
There was a problem hiding this comment.
This contains whitespace-only changes, can be discarded if not required for linting purpose
Comment on lines
+94
to
+97
| requester.id in moderator_user_ids or | ||
| requester.id in ta_user_ids or | ||
| requester.id in course_staff_user_ids or | ||
| is_global_staff |
There was a problem hiding this comment.
Just a suggestion, we may not need to implement it
all_privileged_ids = ( moderator_user_ids | ta_user_ids | course_staff_user_ids)
has_moderation_privilege = requester.id in all_privileged_ids or is_global_staff
Possible change, not required strictly
Comment on lines
+267
to
+271
| course_id = ( | ||
| view.kwargs.get("course_id") or | ||
| request.query_params.get("course_id") or | ||
| (request.data.get("course_id") if hasattr(request, 'data') else None) | ||
| ) |
There was a problem hiding this comment.
Do we need these many safety nets ? won't view.kwargs.get be enough ?
| site_key = get_captcha_site_key_by_platform(get_platform_from_request()) | ||
| url = (f"https://recaptchaenterprise.googleapis.com/v1/projects/{settings.RECAPTCHA_PROJECT_ID}/assessments" | ||
| f"?key={settings.RECAPTCHA_PRIVATE_KEY}") | ||
| url = ("https://recaptchaenterprise.googleapis.com/v1/projects/{}/assessments" |
There was a problem hiding this comment.
Linting related changes ?
If otherwise, changes can be removed. Keep changes as is if linting related issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces new features and improvements to the discussion moderation system, focusing on user banning, bulk delete and ban operations, and enhanced permission checks. It adds new serializers and API logic for banning users, ensures banned users are excluded from discussion stats, and introduces robust email notifications for ban escalations. Permission logic for moderation actions is clarified and strengthened, and the bulk delete task is updated to support banning users with retry logic.
Key changes:
User Banning and Moderation Logic
create_threadandcreate_commentto prevent banned users from posting in course discussions, raising aPermissionDeniederror if the user is banned. [1] [2]get_course_discussion_user_stats.Serializers and API Enhancements
BulkDeleteBanRequestSerializer,BanUserRequestSerializer, andBannedUserSerializerto support bulk delete and ban actions, standalone bans, and listing banned users, with validation and user normalization logic.course_idand ensure staff/moderator privilege checks include course staff.Permissions and Access Control
can_take_action_on_spamfunction andIsAllowedToBulkDeletepermission class to grant bulk delete and ban permissions to global staff, course staff, instructors, and forum moderators/administrators, while restricting access for students and community TAs.Email Notifications for Moderation
emails.pymodule to send escalation emails when a user is banned, using ACE (Automated Communications Engine) if available, with fallback to Django email. The email includes details about the ban, moderator, course, and content deleted.Bulk Delete and Ban Task Improvements
delete_course_post_for_userCelery task to support optional user banning, ban scope, moderator, and reason parameters. Added retry logic with exponential backoff for transient errors.Minor Improvements
filter_spam_urls_from_html.These changes collectively strengthen discussion moderation, provide better auditability, and improve the experience for moderators and staff
Description
Describe what this pull request changes, and why. Include implications for people using this change.
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
OEP-19, and can be
linked here.
Useful information to include:
"Developer", and "Operator".
changes.
Supporting information
Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.
Testing instructions
Please provide detailed step-by-step instructions for testing this change.
Deadline
"None" if there's no rush, or provide a specific date or event (and reason) if there is one.
Other information
Include anything else that will help reviewers and consumers understand the change.