Merge pull request #111 from QingdaoU/fix

This commit is contained in:
zema1 2017-12-20 10:22:29 +08:00 committed by GitHub
commit d081d7ee76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

3
.gitignore vendored
View File

@ -71,3 +71,6 @@ data/public/upload/*
data/public/avatar/*
!data/public/avatar/default.png
http_locations.conf
https_locations.conf

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
APP=/app
DATA=/data

View File

@ -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",