Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change permission to view your own solutions after deadline #265

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading