mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 16:41:56 +00:00
Merge pull request #111 from QingdaoU/fix
This commit is contained in:
commit
d081d7ee76
3
.gitignore
vendored
3
.gitignore
vendored
@ -71,3 +71,6 @@ data/public/upload/*
|
||||
data/public/avatar/*
|
||||
!data/public/avatar/default.png
|
||||
|
||||
http_locations.conf
|
||||
https_locations.conf
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
APP=/app
|
||||
DATA=/data
|
||||
|
@ -90,6 +90,12 @@ class BaseProblemSerializer(serializers.ModelSerializer):
|
||||
tags = serializers.SlugRelatedField(many=True, slug_field="name", read_only=True)
|
||||
created_by = UsernameSerializer()
|
||||
|
||||
def get_public_template(self, obj):
|
||||
ret = {}
|
||||
for lang, code in obj.template.items():
|
||||
ret[lang] = parse_problem_template(code)["template"]
|
||||
return ret
|
||||
|
||||
|
||||
class ProblemAdminSerializer(BaseProblemSerializer):
|
||||
class Meta:
|
||||
@ -98,13 +104,7 @@ class ProblemAdminSerializer(BaseProblemSerializer):
|
||||
|
||||
|
||||
class ProblemSerializer(BaseProblemSerializer):
|
||||
template = serializers.SerializerMethodField()
|
||||
|
||||
def get_template(self, obj):
|
||||
ret = {}
|
||||
for lang, code in obj.template.items():
|
||||
ret[lang] = parse_problem_template(code)["template"]
|
||||
return ret
|
||||
template = serializers.SerializerMethodField("get_public_template")
|
||||
|
||||
class Meta:
|
||||
model = Problem
|
||||
@ -113,6 +113,8 @@ class ProblemSerializer(BaseProblemSerializer):
|
||||
|
||||
|
||||
class ProblemSafeSerializer(BaseProblemSerializer):
|
||||
template = serializers.SerializerMethodField("get_public_template")
|
||||
|
||||
class Meta:
|
||||
model = Problem
|
||||
exclude = ("test_case_score", "test_case_id", "visible", "is_public",
|
||||
|
Loading…
Reference in New Issue
Block a user