增加处理submission的serializer

This commit is contained in:
virusdefender 2016-04-23 15:09:56 +08:00
parent e1e887b5d6
commit 2948d0c9e0
No known key found for this signature in database
GPG Key ID: 1686FB5677979E61

View File

@ -4,7 +4,7 @@ import json
from rest_framework import serializers
from robots.utils import Language
from .models import Problem
from .models import Problem, Submission
class JSONField(serializers.Field):
@ -22,4 +22,12 @@ class ProblemSerializer(serializers.ModelSerializer):
class CreateSubmissionSerializer(serializers.Serializer):
problem_id = serializers.CharField(max_length=32)
language = serializers.ChoiceField(choices=[Language.C, Language.CPP, Language.Java])
code = serializers.CharField(max_length=10000)
code = serializers.CharField(max_length=10000)
class SubmissionSerializer(serializers.ModelSerializer):
info = JSONField()
class Meta:
model = Submission
exclude = ["submit_task_id", "task_id", "robot_user", "origin_submission_id", "api_key"]