Add view public submissions permission
This commit is contained in:
parent
fdb71ba3c4
commit
eb44b6510a
4 changed files with 26 additions and 0 deletions
|
@ -17,6 +17,12 @@ def submission_layout(
|
|||
if user.has_perm("judge.change_submission"):
|
||||
can_view = True
|
||||
|
||||
if user.has_perm("judge.view_all_submission"):
|
||||
can_view = True
|
||||
|
||||
if user.has_perm("judge.view_public_submission"):
|
||||
can_view = True
|
||||
|
||||
if submission.problem_id in completed_problem_ids:
|
||||
can_view |= (
|
||||
submission.problem.is_public or profile_id in submission.problem.tester_ids
|
||||
|
|
17
judge/migrations/0127_auto_20220616_1442.py
Normal file
17
judge/migrations/0127_auto_20220616_1442.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 2.2.25 on 2022-06-16 07:42
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('judge', '0126_languagetemplate'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='submission',
|
||||
options={'permissions': (('abort_any_submission', 'Abort any submission'), ('rejudge_submission', 'Rejudge the submission'), ('rejudge_submission_lot', 'Rejudge a lot of submissions'), ('spam_submission', 'Submit without limit'), ('view_all_submission', 'View all submission'), ('resubmit_other', "Resubmit others' submission"), ('view_public_submission', 'View public submissions')), 'verbose_name': 'submission', 'verbose_name_plural': 'submissions'},
|
||||
),
|
||||
]
|
|
@ -230,6 +230,7 @@ class Submission(models.Model):
|
|||
("spam_submission", "Submit without limit"),
|
||||
("view_all_submission", "View all submission"),
|
||||
("resubmit_other", "Resubmit others' submission"),
|
||||
("view_public_submission", "View public submissions"),
|
||||
)
|
||||
verbose_name = _("submission")
|
||||
verbose_name_plural = _("submissions")
|
||||
|
|
|
@ -88,6 +88,8 @@ class SubmissionDetailBase(LoginRequiredMixin, TitleMixin, SubmissionMixin, Deta
|
|||
problem = submission.problem
|
||||
if self.request.user.has_perm("judge.view_all_submission"):
|
||||
return submission
|
||||
if problem.is_public and self.request.user.has_perm("judge.view_public_submission"):
|
||||
return submission
|
||||
if submission.user_id == profile.id:
|
||||
return submission
|
||||
if problem.is_editor(profile):
|
||||
|
|
Loading…
Reference in a new issue