<s> import json <EOL> from rest_framework import serializers <EOL> from django . utils import timezone <EOL> import datetime <EOL> from account . models import User <EOL> from account . serializers import UserSerializer <EOL> from . models import Contest , ContestProblem <EOL> class CreateContestSerializer ( serializers . Serializer ) : <EOL> title = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> contest_type = serializers . IntegerField ( ) <EOL> real_time_rank = serializers . BooleanField ( ) <EOL> password = serializers . CharField ( max_length = <NUM_LIT:30> , required = False , default = None ) <EOL> start_time = serializers . DateTimeField ( ) <EOL> end_time = serializers . DateTimeField ( ) <EOL> groups = serializers . ListField ( child = serializers . IntegerField ( ) , required = False , default = [ ] ) <EOL> visible = serializers . BooleanField ( ) <EOL> class DateTimeLocal ( serializers . DateTimeField ) : <EOL> def to_representation ( self , value ) : <EOL> return timezone . localtime ( value ) <EOL> class ContestSerializer ( serializers . ModelSerializer ) : <EOL> class UserSerializer ( serializers . ModelSerializer ) : <EOL> class Meta : <EOL> model = User <EOL> fields = [ "<STR_LIT:username>" ] <EOL> created_by = UserSerializer ( ) <EOL> start_time = DateTimeLocal ( ) <EOL> end_time = DateTimeLocal ( ) <EOL> class Meta : <EOL> model = Contest <EOL> class EditContestSerializer ( serializers . Serializer ) : <EOL> id = serializers . IntegerField ( ) <EOL> title = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> description = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> contest_type = serializers . IntegerField ( ) <EOL> real_time_rank = serializers . BooleanField ( ) <EOL> password = serializers . CharField ( max_length = <NUM_LIT:30> , required = False , default = None ) <EOL> start_time = serializers . DateTimeField ( ) <EOL> end_time = serializers . DateTimeField ( ) <EOL> groups = serializers . ListField ( child = serializers . IntegerField ( ) , required = False , default = [ ] ) <EOL> visible = serializers . BooleanField ( ) <EOL> class ContestProblemSampleSerializer ( 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 CreateContestProblemSerializer ( serializers . Serializer ) : <EOL> contest_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> samples = ContestProblemSampleSerializer ( ) <EOL> test_case_id = serializers . CharField ( max_length = <NUM_LIT> ) <EOL> time_limit = serializers . IntegerField ( ) <EOL> memory_limit = serializers . IntegerField ( ) <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> hint = serializers . CharField ( max_length = <NUM_LIT> , allow_blank = True ) <EOL> score = serializers . IntegerField ( required = False , default = <NUM_LIT:0> ) <EOL> sort_index = serializers . CharField ( max_length = <NUM_LIT:30> ) <EOL> class ContestProblemSerializer ( serializers . ModelSerializer ) : <EOL> class ContestSerializer ( serializers . ModelSerializer ) : <EOL> class Meta : <EOL> model = Contest <EOL> fields = [ "<STR_LIT:title>" , "<STR_LIT:id>" ] <EOL> samples = JSONField ( ) <EOL> contest = ContestSerializer ( ) <EOL> created_by = UserSerializer ( ) <EOL> class Meta : <EOL> model = ContestProblem <EOL> class EditContestProblemSerializer ( 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> time_limit = serializers . IntegerField ( ) <EOL> memory_limit = serializers . IntegerField ( ) <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> samples = ContestProblemSampleSerializer ( ) <EOL> hint = serializers . CharField ( max_length = <NUM_LIT> , allow_blank = True ) <EOL> visible = serializers . BooleanField ( ) <EOL> sort_index = serializers . CharField ( max_length = <NUM_LIT:30> ) <EOL> score = serializers . IntegerField ( required = False , default = <NUM_LIT:0> ) <EOL> class ContestPasswordVerifySerializer ( serializers . Serializer ) : <EOL> contest_id = serializers . IntegerField ( ) <EOL> password = serializers . CharField ( max_length = <NUM_LIT:30> ) </s>
