feat: add functionality to publish contest problems and their associa…#569
feat: add functionality to publish contest problems and their associa…#569whlongg wants to merge 1 commit intoVNOI-Admin:masterfrom
Conversation
There was a problem hiding this comment.
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.
| self.client.post(self._get_url()) | ||
|
|
There was a problem hiding this comment.
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.
| self.client.post(self._get_url()) | |
| response = self.client.post(self._get_url()) | |
| self.assertEqual(response.status_code, 403) |
| 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) | ||
|
|
There was a problem hiding this comment.
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.
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
Checklist
Put an
xin 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.By submitting this pull request, I confirm that my contribution is made under the terms of the AGPL-3.0 License.