Skip to content

feat: add separate allow_public_comments field for bots#4588

Draft
SylvainChevalier wants to merge 4 commits intomainfrom
claude/issue-4583-20260407-1249
Draft

feat: add separate allow_public_comments field for bots#4588
SylvainChevalier wants to merge 4 commits intomainfrom
claude/issue-4583-20260407-1249

Conversation

@SylvainChevalier
Copy link
Copy Markdown
Contributor

Add a new allow_public_comments boolean field to the User model, separate from is_primary_bot which is used for scoring. This gives admins fine-grained control over which bots can post public comments without affecting scoring behavior.

  • New field defaults to False (bots can only post private comments)
  • Informative error message when bots try to post public comments
  • Admin UI updated to expose the new field
  • DB constraint ensures only bot accounts can have the flag set

Closes #4583

Add a new `allow_public_comments` boolean field to the User model,
separate from `is_primary_bot` which is used for scoring. This gives
admins fine-grained control over which bots can post public comments
without affecting scoring behavior.

- New field defaults to False (bots can only post private comments)
- Informative error message when bots try to post public comments
- Admin UI updated to expose the new field
- DB constraint ensures only bot accounts can have the flag set

Closes #4583

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c3b47a8e-8bf2-4d99-87fd-3d4479d831c9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-4583-20260407-1249

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4588-claude-issue-4583-20260407-124-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:claude-issue-4583-20260407-1249-4275466
🗄️ PostgreSQL NeonDB branch preview/pr-4588-claude-issue-4583-20260407-124
Redis Fly Redis mtc-redis-pr-4588-claude-issue-4583-20260407-124

Details

  • Commit: 4275466db89a25e012f7bfd59f9698b704baa057
  • Branch: claude/issue-4583-20260407-1249
  • Fly App: metaculus-pr-4588-claude-issue-4583-20260407-124

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

@SylvainChevalier
Copy link
Copy Markdown
Contributor Author

@claude let's make the field allow_public_comments_if_bot so it's clear it doesn't apply to humans. Unless you have a better name idea?

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 8, 2026

Claude finished @SylvainChevalier's task in 1m 40s —— View job


Renamed allow_public_commentsallow_public_comments_if_bot

  • Read current implementation
  • Rename field in users/models.py
  • Update migration users/migrations/0019_add_allow_public_comments.py
  • Update users/admin.py
  • Update comments/services/common.py
  • Update tests/unit/test_comments/test_services.py
  • Commit and push

Renamed the field and its DB constraint across all 5 files. The new name makes it immediately clear this field only applies to bot accounts.
|

Make the field name self-documenting: it only applies to bot accounts.

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
@SylvainChevalier
Copy link
Copy Markdown
Contributor Author

@claude please fix the unit test problems.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 8, 2026

Claude finished @SylvainChevalier's task in 5m 55s —— View job


Fixing Unit Test Problems

  • Gather context on test file and related code
  • Identify CI failures from Run Unit Tests: Ruff formatting + missing migration
  • Fix Ruff formatting in users/admin.py (wrap long fields list in BotInline)
  • Fix Ruff formatting in users/models.py (wrap long constraint check= expression)
  • Add missing migration 0020_alter_user_is_primary_bot.py for is_primary_bot help_text change
  • Commit and push fixes

The CI had two failures in Backend Checks:

  1. Ruff formattingusers/admin.py and users/models.py had lines exceeding the 88-char limit from the new allow_public_comments_if_bot field additions
  2. Missing migration — The is_primary_bot help_text was updated (removing "Only the primary bot can post public comments") but no migration was generated for it

Both are now fixed in commit ee3ed2c.
| Branch

- Fix line-too-long in users/admin.py (BotInline fields list)
- Fix line-too-long in users/models.py (constraint check expression)
- Add migration 0020 for is_primary_bot help_text change

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
@SylvainChevalier
Copy link
Copy Markdown
Contributor Author

@claude please fix the unit test problems.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 20, 2026

Claude encountered an error —— View job


Fixing Unit Test Problems

  • Gather context on CI failures
  • Identify and fix test issues
  • Commit and push fixes

@hlbmtc
Copy link
Copy Markdown
Contributor

hlbmtc commented Apr 28, 2026

@claude Resume

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 28, 2026

Claude finished @hlbmtc's task in 2m 35s —— View job


Fixed CI: Check migrations failure

  • Check CI status — found Backend Checks > Check migrations failed
  • Identify root cause
  • Apply fix
  • Commit and push

Root cause

The previous CI run (before retry) reported all unit tests passing (715 passed). The actual failure was in the Check migrations step of the Backend Checks job, which runs manage.py makemigrations --dry-run --check:

Migrations for 'users':
  users/migrations/0021_alter_user_is_primary_bot.py
    ~ Alter field is_primary_bot on user
##[error]Process completed with exit code 1.

In users/models.py:127, the is_primary_bot help_text used a curly Unicode right-single-quotation-mark (', U+2019), but the matching migration 0020_alter_user_is_primary_bot.py:18 used a regular ASCII apostrophe (', U+0027). Django's autodetector saw the strings as different and demanded a new migration.

Fix

Replaced the curly apostrophe in users/models.py with a regular ASCII apostrophe so it matches 0020_alter_user_is_primary_bot.py. No new migration needed.

Pushed as commit 4275466.
| Branch

The help_text in the model used a Unicode right-single-quotation-mark
(U+2019), while migration 0020 used a regular ASCII apostrophe.
Django's makemigrations detected this mismatch and demanded a new
migration. Aligning the model with the migration resolves the
"Check migrations" CI failure.

Co-authored-by: Hlib <hlbmtc@users.noreply.github.com>
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.

Don't let bots post public comments by default

2 participants