-
Notifications
You must be signed in to change notification settings - Fork 0
Fix broken exports for training programs #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken exports for training programs #110
Conversation
1. Add 'Export all tasks' button to training program general page - Added export link that exports the managing contest's tasks 2. Fix training day export to use get_tasks() instead of contest.tasks - Training days have tasks separate from contest.tasks - Updated _export_contest_to_yaml_format to use get_tasks() 3. Rename managing contest to match training program name - Changed from '__' + name to just name - Updated contest filtering to check if contest is a managing contest - Updated exclude_internal_contests() to filter managing contests - Updated CWS and AWS handlers to check training_program relationship Co-Authored-By: Ron Ryvchin <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the
📝 WalkthroughWalkthroughThis pull request introduces an export capability for training programs via a new ExportTrainingProgramHandler, refactors contest resolution to use explicit training_program relationships instead of name-based heuristics, removes the "__" prefix convention from contest names, and updates contest filtering to exclude training-program-managed contests. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-Authored-By: Ron Ryvchin <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@cms/server/contest/handlers/contest.py`:
- Around line 179-181: The direct-access branch blocks "__" names but doesn't
set self.training_program for managing contests; update the block that checks
self.contest.name.startswith("__") to also, when the current contest is a
managing contest, set self.training_program = self.contest.training_program
(same logic used in the single-contest path where contest.training_program is
assigned) so that can_access_task() and StudentTask checks see the training
program; ensure you follow the same null/exists checks used in the
single-contest assignment to avoid None propagation.
🧹 Nitpick comments (1)
cms/server/admin/handlers/export_handlers.py (1)
607-612: Nit: Rename unused loop variable.The static analysis tool flags
dirsas unused in theos.walkloop. While this is a common pattern, renaming to_dirswould suppress the warning and signal intent.♻️ Optional fix
- for root, dirs, files in os.walk(contest_dir): + for root, _dirs, files in os.walk(contest_dir):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Fix broken exports for training programs 1. Add 'Export all tasks' button to training program general page - Added export link that exports the managing contest's tasks 2. Fix training day export to use get_tasks() instead of contest.tasks - Training days have tasks separate from contest.tasks - Updated _export_contest_to_yaml_format to use get_tasks() 3. Rename managing contest to match training program name - Changed from '__' + name to just name - Updated contest filtering to check if contest is a managing contest - Updated exclude_internal_contests() to filter managing contests - Updated CWS and AWS handlers to check training_program relationship Co-Authored-By: Ron Ryvchin <[email protected]> * Fix export button URL and add training program export route Co-Authored-By: Ron Ryvchin <[email protected]> * review comments * Add pictures to dump exporter * export fix --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Ron Ryvchin <[email protected]>
Summary
This PR addresses three issues with training program exports:
Added "Export all tasks" button to training program general page - Training programs now have an export link similar to contests, which exports all tasks from the managing contest.
Fixed training day export - Changed
_export_contest_to_yaml_formatto usecontest.get_tasks()instead ofcontest.tasks. Training days store their tasks separately, so the previous code would export an empty task list.Changed managing contest naming convention - Managing contests are now created with the same name as the training program (instead of
__prefix). Updated contest filtering logic to check thetraining_programrelationship instead of relying solely on the__prefix. Backward compatibility is maintained for existing__prefixed contests.Review & Testing Checklist for Human
__prefix. Test that these still work correctly (access control, filtering, redirects).__prefix) and that it's properly hidden from contest lists.__prefix) managing contests.Notes
exclude_internal_contests()utility function now filters out both__prefixed contests AND contests that are managing contests for training programs.__prefix. This creates some inconsistency but maintains backward compatibility.Link to Devin run: https://app.devin.ai/sessions/4d6920a93a8e45e79c033dbb2c871908
Requested by: Ron Ryvchin (@ronryv)
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.