<s> import json <EOL> from rest_framework import serializers <EOL> from account . models import User <EOL> from . models import Problem , ProblemTag <EOL> class ProblemSampleSerializer ( serializers . ListField ) : <EOL> input = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> output = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> class JSONField ( serializers . Field ) : <EOL> def to_representation ( self , value ) : <EOL> return json . loads ( value ) <EOL> class CreateProblemSerializer ( serializers . Serializer ) : <EOL> title = serializers . CharField ( max_length = <NUM_LIT:50> ) <EOL> description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> input_description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> output_description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> samples = ProblemSampleSerializer ( ) <EOL> test_case_id = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> time_limit = serializers . IntegerField ( min_value = <NUM_LIT:1> , max_value = <NUM_LIT> ) <EOL> memory_limit = serializers . IntegerField ( min_value = <NUM_LIT:16> ) <EOL> spj = serializers . BooleanField ( ) <EOL> spj_language = serializers . IntegerField ( required = False , default = None ) <EOL> spj_code = serializers . CharField ( max_length = <NUM_LIT> , required = False , default = None ) <EOL> difficulty = serializers . IntegerField ( ) <EOL> tags = serializers . ListField ( child = serializers . CharField ( max_length = <NUM_LIT:10> ) ) <EOL> hint = serializers . CharField ( max_length = <NUM_LIT> , allow_blank = True ) <EOL> source = serializers . CharField ( max_length = <NUM_LIT:100> , required = False , default = None ) <EOL> visible = serializers . BooleanField ( ) <EOL> class ProblemTagSerializer ( serializers . ModelSerializer ) : <EOL> class Meta : <EOL> model = ProblemTag <EOL> class BaseProblemSerializer ( serializers . ModelSerializer ) : <EOL> samples = JSONField ( ) <EOL> tags = ProblemTagSerializer ( many = True ) <EOL> class UserSerializer ( serializers . ModelSerializer ) : <EOL> class Meta : <EOL> model = User <EOL> fields = [ "<STR_LIT:username>" ] <EOL> created_by = UserSerializer ( ) <EOL> class ProblemSerializer ( BaseProblemSerializer ) : <EOL> class Meta : <EOL> model = Problem <EOL> class OpenAPIProblemSerializer ( BaseProblemSerializer ) : <EOL> class Meta : <EOL> model = Problem <EOL> exclude = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> class EditProblemSerializer ( serializers . Serializer ) : <EOL> id = serializers . IntegerField ( ) <EOL> title = serializers . CharField ( max_length = <NUM_LIT:50> ) <EOL> description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> input_description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> output_description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> test_case_id = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> source = serializers . CharField ( max_length = <NUM_LIT:100> ) <EOL> time_limit = serializers . IntegerField ( min_value = <NUM_LIT:1> ) <EOL> memory_limit = serializers . IntegerField ( min_value = <NUM_LIT:1> ) <EOL> spj = serializers . BooleanField ( ) <EOL> spj_language = serializers . IntegerField ( required = False , default = None ) <EOL> spj_code = serializers . CharField ( max_length = <NUM_LIT> , required = False , default = None ) <EOL> difficulty = serializers . IntegerField ( ) <EOL> tags = serializers . ListField ( child = serializers . CharField ( max_length = <NUM_LIT:20> ) ) <EOL> samples = ProblemSampleSerializer ( ) <EOL> hint = serializers . CharField ( max_length = <NUM_LIT> , allow_blank = True ) <EOL> visible = serializers . BooleanField ( ) </s>
