mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-04 03:22:06 +00:00
29 lines
771 B
Python
29 lines
771 B
Python
# coding=utf-8
|
|
from rest_framework import serializers
|
|
|
|
from account.models import User
|
|
from .models import Submission
|
|
|
|
|
|
class CreateSubmissionSerializer(serializers.Serializer):
|
|
problem_id = serializers.IntegerField()
|
|
language = serializers.IntegerField()
|
|
code = serializers.CharField(max_length=3000)
|
|
|
|
|
|
class SubmissionSerializer(serializers.ModelSerializer):
|
|
user = serializers.SerializerMethodField("_get_submission_user")
|
|
|
|
class Meta:
|
|
model = Submission
|
|
fields = ["id", "result", "create_time", "language", "user"]
|
|
|
|
def _get_submission_user(self, obj):
|
|
return User.objects.get(id=obj.user_id).username
|
|
|
|
|
|
class SubmissionhareSerializer(serializers.Serializer):
|
|
submission_id = serializers.CharField(max_length=40)
|
|
|
|
|