Skip to content

feat: add functionality to publish contest problems and their associa…#569

Open
whlongg wants to merge 1 commit intoVNOI-Admin:masterfrom
whlongg:feat/auto-publish-editorial-on-contest-publish
Open

feat: add functionality to publish contest problems and their associa…#569
whlongg wants to merge 1 commit intoVNOI-Admin:masterfrom
whlongg:feat/auto-publish-editorial-on-contest-publish

Conversation

@whlongg
Copy link
Copy Markdown
Contributor

@whlongg whlongg commented Apr 5, 2026

fixes #566

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Please remove options that are not relevant
Type of change: bug fix, new feature, refactor, or something else?

What

What does the PR do?

Why

Why this PR is needed?

Fixes # (issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have explained the purpose of this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the README/documentation
  • Any dependent changes have been merged and published in downstream modules
  • Informed of breaking changes, testing and migrations (if applicable).
  • Attached screenshots (if applicable).

By submitting this pull request, I confirm that my contribution is made under the terms of the AGPL-3.0 License.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for automatically publishing a problem’s editorial when a contest organizer uses the “publish all contest problems” action, addressing issue #566.

Changes:

  • Update the contest “make problems public” endpoint to also publish associated Solution (editorial) records immediately.
  • Add Django view tests covering publishing behavior, permissions, and rescore-task triggering.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
judge/views/contests.py Publishes the associated editorial (Solution) when a contest problem is made public.
judge/views/tests/test_contest.py Adds regression tests for publishing contest problems and editorials, plus permission/rescore behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +143 to +144
self.client.post(self._get_url())

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In test_normal_user_permission_denied, consider asserting the response status (expected 403 from PermissionDenied) so the test fails if the view ever stops enforcing the permission check but still happens not to publish anything due to other reasons.

Suggested change
self.client.post(self._get_url())
response = self.client.post(self._get_url())
self.assertEqual(response.status_code, 403)

Copilot uses AI. Check for mistakes.
Comment on lines 1484 to +1488
problem.save(update_fields=['is_public', 'date'])
rescore_problem.delay(problem.id, True)

Solution.objects.filter(problem=problem).update(is_public=True, publish_on=now)

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution.objects.filter(problem=problem).update(...) runs once per contest problem, adding an extra UPDATE query per published problem. Since Solution is one-to-one with Problem, you could collect the IDs of problems newly published in this request and do a single bulk update at the end (filtering on problem_id__in) to reduce query count for contests with many problems.

Copilot uses AI. Check for mistakes.
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.

Auto publish problem editorial when publish problem in a contest

2 participants