Skip to content

Commit d47c307

Browse files
committed
Locking after contest, oops
1 parent 5180989 commit d47c307

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ctfapp/decorators.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.core.exceptions import PermissionDenied
33
from django.shortcuts import render
44

5-
from ctfapp.utils.time import before_start
5+
from ctfapp.utils.time import before_start, after_end
66

77
from functools import wraps
88

@@ -36,3 +36,13 @@ def wrap(request, *args, **kwargs):
3636
return view(request, *args, **kwargs)
3737

3838
return wrap
39+
40+
def lock_after_contest(view):
41+
@wraps(view, assigned=available_attrs(view))
42+
def wrap(request, *args, **kwargs):
43+
if after_end() and not request.user.is_staff:
44+
return render(request, 'denied.html', {})
45+
else:
46+
return view(request, *args, **kwargs)
47+
48+
return wrap

ctfapp/views/submit_problem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.utils import timezone
99

1010
from ctfapp.models import Problem, CorrectSubmission, IncorrectSubmission
11-
from ctfapp.decorators import team_required, lock_before_contest
11+
from ctfapp.decorators import team_required, lock_before_contest, lock_after_contest
1212

1313
# This file handles problem grading and the display for grading.
1414

@@ -17,6 +17,7 @@
1717
@login_required
1818
@team_required
1919
@lock_before_contest
20+
@lock_after_contest
2021
def submit_problem(request: HttpRequest):
2122
"""
2223
View for submitting a problem through AJAX. Login is required.

0 commit comments

Comments
 (0)