From 61a5d10326f1eb0b0d8b7b5bca283a0c64eabfbc Mon Sep 17 00:00:00 2001 From: vikibrezinova Date: Sun, 12 Nov 2023 11:57:05 +0100 Subject: [PATCH] change permission to view your own solutions --- competition/permissions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/competition/permissions.py b/competition/permissions.py index 138a15e4..be2ba974 100644 --- a/competition/permissions.py +++ b/competition/permissions.py @@ -61,11 +61,18 @@ def has_permission(self, request, view): return super().has_permission(request, view) def has_object_permission(self, request, view, obj): - if view.action in ['upload_solution', 'my_solution', 'corrected_solution']: + if view.action == 'upload_solution': return ( request.user.is_authenticated and EventRegistration.get_registration_by_profile_and_event( request.user.profile, obj.series.semester) ) and obj.series.can_submit + if view.action in ['my_solution', 'corrected_solution']: + return ( + request.user.is_authenticated and + EventRegistration.get_registration_by_profile_and_event( + request.user.profile, obj.series.semester)) + + return super().has_object_permission(request, view, obj)