mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-27 23:51:47 +00:00
比赛题目也可以分享
This commit is contained in:
parent
61b07dfc4c
commit
0a55385f25
@ -1,4 +1,6 @@
|
||||
from django.db import models
|
||||
|
||||
from utils.constants import ContestStatus
|
||||
from utils.models import JSONField
|
||||
from problem.models import Problem
|
||||
from contest.models import Contest
|
||||
@ -39,12 +41,15 @@ class Submission(models.Model):
|
||||
ip = models.TextField(null=True)
|
||||
|
||||
def check_user_permission(self, user, check_share=True):
|
||||
return self.user_id == user.id or \
|
||||
(check_share and self.shared is True) or \
|
||||
(check_share and self.problem.share_submission) or \
|
||||
user.is_super_admin() or \
|
||||
user.can_mgmt_all_problem() or \
|
||||
self.problem.created_by_id == user.id
|
||||
if self.user_id == user.id or user.is_super_admin() or user.can_mgmt_all_problem() or self.problem.created_by_id == user.id:
|
||||
return True
|
||||
|
||||
if check_share:
|
||||
if self.contest and self.contest.status != ContestStatus.CONTEST_ENDED:
|
||||
return False
|
||||
if self.problem.share_submission or self.shared:
|
||||
return True
|
||||
return False
|
||||
|
||||
class Meta:
|
||||
db_table = "submission"
|
||||
|
Loading…
Reference in New Issue
Block a user