Skip to content

Commit

Permalink
change permission to view your own solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
vikibrezinova committed Nov 12, 2023
1 parent 2411e94 commit 61a5d10
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion competition/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 61a5d10

Please sign in to comment.