Skip to content

Commit

Permalink
Merge pull request #265 from ZdruzenieSTROM/view_solution_after_deadline
Browse files Browse the repository at this point in the history
Change permission to view your own solutions after deadline
  • Loading branch information
vikibrezinova authored Nov 12, 2023
2 parents 14ce5b2 + c2952d1 commit d7dd2be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion competition/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ 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 d7dd2be

Please sign in to comment.