mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-16 01:13:47 +00:00
去掉dataTime的格式化,因为格式化后moment.js不能识别为标准时间
This commit is contained in:
parent
8a60ea52bb
commit
ee2f5f5dd7
@ -25,7 +25,7 @@ class ContestSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Contest
|
model = Contest
|
||||||
|
exclude = ('password', 'visible')
|
||||||
|
|
||||||
class EditConetestSeriaizer(serializers.Serializer):
|
class EditConetestSeriaizer(serializers.Serializer):
|
||||||
id = serializers.IntegerField()
|
id = serializers.IntegerField()
|
||||||
|
@ -89,52 +89,3 @@ class SubmissionListAPI(APIView):
|
|||||||
return self.success(data)
|
return self.success(data)
|
||||||
|
|
||||||
|
|
||||||
def _get_submission(submission_id, user):
|
|
||||||
"""
|
|
||||||
用户权限判断
|
|
||||||
"""
|
|
||||||
submission = Submission.objects.get(id=submission_id)
|
|
||||||
# Super Admin / Owner / Share
|
|
||||||
if user.admin_type == AdminType.SUPER_ADMIN or submission.user_id == user.id:
|
|
||||||
return {"submission": submission, "can_share": True}
|
|
||||||
if submission.contest_id:
|
|
||||||
# 比赛部分
|
|
||||||
pass
|
|
||||||
if submission.shared:
|
|
||||||
return {"submission": submission, "can_share": False}
|
|
||||||
else:
|
|
||||||
raise Submission.DoesNotExist
|
|
||||||
|
|
||||||
|
|
||||||
class SubmissionDetailAPI(APIView):
|
|
||||||
"""
|
|
||||||
单个提交页面详情
|
|
||||||
"""
|
|
||||||
|
|
||||||
def get(self, request, **kwargs):
|
|
||||||
try:
|
|
||||||
result = _get_submission(kwargs["submission_id"], request.user)
|
|
||||||
submission = result["submission"]
|
|
||||||
except Submission.DoesNotExist:
|
|
||||||
return self.error("Submission not exist")
|
|
||||||
|
|
||||||
# TODO: Contest
|
|
||||||
try:
|
|
||||||
if submission.contest_id:
|
|
||||||
# problem = ContestProblem.objects.get(id=submission.problem_id, visible=True)
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
problem = Problem.objects.get(id=submission.problem_id, visible=True)
|
|
||||||
except (Problem.DoesNotExist,):
|
|
||||||
return self.error("Submission not exist")
|
|
||||||
|
|
||||||
if submission.result in [JudgeStatus.COMPILE_ERROR, JudgeStatus.SYSTEM_ERROR, JudgeStatus.PENDING]:
|
|
||||||
info = submission.info
|
|
||||||
else:
|
|
||||||
info = submission.info
|
|
||||||
if "test_case" in info[0]:
|
|
||||||
info = sorted(info, key=lambda x: x["test_case"])
|
|
||||||
|
|
||||||
user = User.objects.get(id=submission.user_id)
|
|
||||||
return self.success({"submission": submission, "problem": problem, "info": info,
|
|
||||||
"user": user, "can_share": result["can_share"]})
|
|
||||||
|
@ -4,7 +4,7 @@ from rest_framework import serializers
|
|||||||
|
|
||||||
class DateTimeTZField(serializers.DateTimeField):
|
class DateTimeTZField(serializers.DateTimeField):
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
self.format = "%Y-%-m-%d %H:%M:%S %Z"
|
# self.format = "%Y-%-m-%d %H:%M:%S %Z"
|
||||||
value = timezone.localtime(value)
|
value = timezone.localtime(value)
|
||||||
return super(DateTimeTZField, self).to_representation(value)
|
return super(DateTimeTZField, self).to_representation(value)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user