Relax contest submission view
This commit is contained in:
parent
1e35ba864f
commit
78b818901e
3 changed files with 18 additions and 7 deletions
|
@ -333,7 +333,7 @@ class Problem(models.Model):
|
|||
return True
|
||||
return user.has_perm("judge.edit_own_problem") and self.is_editor(user.profile)
|
||||
|
||||
def is_accessible_by(self, user):
|
||||
def is_accessible_by(self, user, in_contest_mode=True):
|
||||
# Problem is public.
|
||||
if self.is_public:
|
||||
# Problem is not private to an organization.
|
||||
|
@ -367,7 +367,7 @@ class Problem(models.Model):
|
|||
|
||||
# If user is currently in a contest containing that problem.
|
||||
current = user.profile.current_contest_id
|
||||
if current is None:
|
||||
if not in_contest_mode or current is None:
|
||||
return False
|
||||
from judge.models import ContestProblem
|
||||
|
||||
|
|
|
@ -506,7 +506,7 @@ class AllUserSubmissions(ConditionalUserTabMixin, UserMixin, SubmissionsListBase
|
|||
class ProblemSubmissionsBase(SubmissionsListBase):
|
||||
show_problem = False
|
||||
dynamic_update = True
|
||||
check_contest_in_access_check = True
|
||||
check_contest_in_access_check = False
|
||||
|
||||
def get_queryset(self):
|
||||
if (
|
||||
|
@ -535,13 +535,16 @@ class ProblemSubmissionsBase(SubmissionsListBase):
|
|||
def access_check_contest(self, request):
|
||||
if self.in_contest and not self.contest.can_see_own_scoreboard(request.user):
|
||||
raise Http404()
|
||||
|
||||
def access_check(self, request):
|
||||
if not self.problem.is_accessible_by(request.user):
|
||||
if not self.contest.is_accessible_by(request.user):
|
||||
raise Http404()
|
||||
|
||||
def access_check(self, request):
|
||||
if self.check_contest_in_access_check:
|
||||
self.access_check_contest(request)
|
||||
else:
|
||||
is_own = hasattr(self, 'is_own') and self.is_own
|
||||
if not is_own and not self.problem.is_accessible_by(request.user, request.in_contest_mode):
|
||||
raise Http404()
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if "problem" not in kwargs:
|
||||
|
@ -740,6 +743,8 @@ class ForceContestMixin(object):
|
|||
|
||||
|
||||
class UserContestSubmissions(ForceContestMixin, UserProblemSubmissions):
|
||||
check_contest_in_access_check = True
|
||||
|
||||
def get_title(self):
|
||||
if self.problem.is_accessible_by(self.request.user):
|
||||
return "%s's submissions for %s in %s" % (
|
||||
|
@ -812,3 +817,9 @@ class UserContestSubmissionsAjax(UserContestSubmissions):
|
|||
total = floatformat(contest_problem.points, -self.contest.points_precision)
|
||||
s.display_point = f"{points} / {total}"
|
||||
return context
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
try:
|
||||
return super(UserContestSubmissionsAjax, self).get(request, *args, **kwargs)
|
||||
except Http404:
|
||||
return HttpResponse(_("You don't have permission to access."))
|
|
@ -6,7 +6,7 @@
|
|||
{% for submission in submissions %}
|
||||
<tr>
|
||||
{% set can_view = submission_layout(submission, profile_id, request.user, editable_problem_ids, completed_problem_ids) %}
|
||||
<td>
|
||||
<td style="padding-right: 1em">
|
||||
{% if submission.contest_time %}
|
||||
{{submission.contest_time}}
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in a new issue