Details
-
Type: Bug
-
Status: Reopened
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: Current Version
-
Fix Version/s: None
-
Component/s: OIOIOI
-
Labels:None
Description
Sometimes when a teacher is adding a contest, the contest is created with an empty `controller_name`, which causes `controller` to be None, which causes tons of AttributeErrors on 2/3 of pages, including the main portal / landing page.
Stacktrace from a sanity check I added to diagnose this issue:
https://sentry.io/the-sio2-project/szkopul/issues/351545304/
{code}
ValueError: Tried to save contest with empty controller
File "oioioi/contests/models.py", line 79, in save
raise ValueError("Tried to save contest with empty controller")
File "oioioi/contests/forms.py", line 76, in save
instance.save()
File "oioioi/base/admin.py", line 333, in add_view
return model_admin.add_view(request, form_url, extra_context)
...
(12 additional frame(s) were not displayed)
ValueError: Tried to save contest with empty controller
{code}
Probable cause:
If there are no rounds specified, this code saves the contest even if it's not supposed to (commit=False):
https://github.com/sio2project/oioioi/blob/master/oioioi/contests/forms.py#L73-L82
Git blame suggests it's been there since the very beginning, I have on idea why this issue didn't appear before.
Stacktrace from a sanity check I added to diagnose this issue:
https://sentry.io/the-sio2-project/szkopul/issues/351545304/
{code}
ValueError: Tried to save contest with empty controller
File "oioioi/contests/models.py", line 79, in save
raise ValueError("Tried to save contest with empty controller")
File "oioioi/contests/forms.py", line 76, in save
instance.save()
File "oioioi/base/admin.py", line 333, in add_view
return model_admin.add_view(request, form_url, extra_context)
...
(12 additional frame(s) were not displayed)
ValueError: Tried to save contest with empty controller
{code}
Probable cause:
If there are no rounds specified, this code saves the contest even if it's not supposed to (commit=False):
https://github.com/sio2project/oioioi/blob/master/oioioi/contests/forms.py#L73-L82
Git blame suggests it's been there since the very beginning, I have on idea why this issue didn't appear before.
At least this round.save():
https://github.com/sio2project/oioioi/blob/master/oioioi/contests/forms.py#L79
Will save the contest even if SimpleContestForm.save is called with commit=False and there were no rounds, as there is no way to insert the new round into the database without inserting the contest first, as there is a foreign key configured.
Maybe something changed with the upgraded version of Django.