Could not delete competition
When trying to remove this competition (as the primary organizer of the competition), we obtain the following error.
https://www.codabench.org/competitions/1002/?secret_key=5781b096-f6a8-49a4-970a-f0f05a3a5d3b
Here is the Django error logs on the platform:
django_1 | Internal Server Error: /api/competitions/1002/
django_1 | Traceback (most recent call last):
django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
django_1 | response = get_response(request)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
django_1 | response = self.process_exception_by_middleware(e, request)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
django_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
django_1 | return view_func(*args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/viewsets.py", line 116, in view
django_1 | return self.dispatch(request, *args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 495, in dispatch
django_1 | response = self.handle_exception(exc)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 455, in handle_exception
django_1 | self.raise_uncaught_exception(exc)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 492, in dispatch
django_1 | response = handler(request, *args, **kwargs)
django_1 | File "/app/src/apps/api/views/competitions.py", line 224, in destroy
django_1 | return super().destroy(request, *args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/mixins.py", line 93, in destroy
django_1 | self.perform_destroy(instance)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/mixins.py", line 97, in perform_destroy
django_1 | instance.delete()
django_1 | File "/app/src/apps/chahub/models.py", line 143, in delete
django_1 | super().delete(*args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 921, in delete
django_1 | collector.collect([self], keep_parents=keep_parents)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/db/models/deletion.py", line 224, in collect
django_1 | field.remote_field.on_delete(self, field, sub_objs, self.using)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/db/models/deletion.py", line 22, in PROTECT
django_1 | raise ProtectedError(
django_1 | django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'Competition' because they are referenced through a protected foreign key: 'Data.competition'", <QuerySet [<Data: fnachalearn - submission(15789)>, <Data: fnachalearn - submission(15790)>]>)
I've seen that the organizer was in status "denied" from the competition, but even when approved the bug remains.
I think this log describe the problem:
django_1 | django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'Competition' because they are referenced through a protected foreign key: 'Data.competition'", <QuerySet [<Data: fnachalearn - submission(15789)>, <Data: fnachalearn - submission(15790)>]>)