Skip to content

Commit

Permalink
(no-ticket) Fix package reupload in PA contests by contest admins
Browse files Browse the repository at this point in the history
When uploading a package to a PA contest, the PA contest controller
adds a selection box for setting the tasks's division to the upload form,
and adds a save_division handler to post-upload handlers,
which saves the task division in problemistance.

When uploading a new problem, this works fine.
When a superadmin reuploads a package, the PA contest controller doesn't
get involved, so all of that is skipped.

However, when a contest admin who isn't a superadmin reuploads a package,
the PA conteset controller does the above two things,
but the save_division handler fails, because it uses 'problem_instance_id'
key from the env, which is set by update_problem_instance handler
only when creating a new problem instance, which doesn't happen on reupload.

Fix this by making update_problem_instance handler also add the
'problem_instance_id' key when it finds a pre-existing problem instance.

Change-Id: I99d89c77a75d645f390601c1bc5c2c0f7794b0f5
  • Loading branch information
Wojciech Dubiel authored and Paweł Dietrich committed Aug 9, 2023
1 parent 0668eaa commit 61d3556
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions oioioi/problems/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ def update_problem_instance(env):
"""
problem = Problem.objects.get(id=env['problem_id'])
if env.get('contest_id', None):
if not ProblemInstance.objects.filter(
pi = ProblemInstance.objects.filter(
contest__id=env['contest_id'], problem=problem
).exists():
).first()
if not pi:
contest = Contest.objects.get(id=env['contest_id'])
pi = get_new_problem_instance(problem, contest)
if env.get('round_id', None) and not pi.round:
pi.round = Round.objects.get(id=env['round_id'])
pi.save()
env['problem_instance_id'] = pi.id
env['problem_instance_id'] = pi.id
if env['is_reupload']:
update_all_probleminstances_after_reupload(problem)

Expand Down

0 comments on commit 61d3556

Please sign in to comment.