Skip to content

Conversation

@mraman-2U
Copy link
Member

This pull request introduces comprehensive support for discussion bans and moderation audit logging in the forum app, including new models, API functions, and migration logic. The main changes are the addition of models for banning users from discussions at both course and organization levels, mechanisms for ban exceptions, and detailed logging of moderation actions. These updates are reflected in both the Django models and the MongoDB backend, along with a migration to set the default source of moderation audit logs to 'ai'.

Discussion Ban and Moderation Models:

  • Added new Django models for DiscussionBan, DiscussionBanException, and DiscussionModerationLog to support course-level and organization-level bans, ban exceptions, and audit logs of moderation actions. Includes constraints, indexes, and denormalized fields for efficient querying.

API Functions for Ban Management:

  • Implemented API functions in forum/api/bans.py for banning users (ban_user), unbanning users (unban_user), retrieving banned users (get_banned_users), and fetching individual bans (get_ban). These handle both course and org scopes, exceptions, and audit logging.

MongoDB Backend Integration:

  • Registered new discussion ban and moderation log models (DiscussionBanExceptions, DiscussionBans, DiscussionModerationLogs) in the MongoDB backend for use in non-relational contexts. [1] [2]

Migration and Audit Log Updates:

  • Added a migration to create the new models, set up constraints and indexes, and update the default value of the source field in ModerationAuditLog to 'ai'. The migration also populates existing records with the new default and provides a reversible operation.
  • Merge checklist:
    Check off if complete or not applicable:
  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

@mraman-2U mraman-2U force-pushed the mraman/bulkdelete-ban-forum branch from b26e61c to 37da952 Compare January 4, 2026 07:02
@mraman-2U mraman-2U force-pushed the mraman/bulkdelete-ban-forum branch from 2454d91 to 0cb0c47 Compare January 8, 2026 09:16
- Remove trailing whitespace from forum/api/bans.py and forum/views/bans.py
- Break long lines to meet 120 character limit
- Add mypy ignore_errors for ban-related modules (type annotations needed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants