Ejemplo n.º 1
0
class CreateEditWebsiteConfigSerializer(serializers.Serializer):
    website_base_url = serializers.CharField(max_length=128)
    website_name = serializers.CharField(max_length=64)
    website_name_shortcut = serializers.CharField(max_length=64)
    website_footer = serializers.CharField(max_length=1024 * 1024)
    allow_register = serializers.BooleanField()
    submission_list_show_all = serializers.BooleanField()
Ejemplo n.º 2
0
class CourseToAddSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    name = serializers.CharField(max_length=20)
    s_year = serializers.CharField(max_length=4)
    short_description = serializers.CharField(max_length=40, required=False)
    is_exist = serializers.BooleanField()
    status = serializers.BooleanField()
Ejemplo n.º 3
0
class CreateSampleSerializer(serializers.Serializer):
    input = serializers.CharField(trim_whitespace=False,
                                  allow_blank=True,
                                  allow_null=True)
    output = serializers.CharField(trim_whitespace=False,
                                   allow_null=True,
                                   allow_blank=True)
Ejemplo n.º 4
0
class UserRegisterSerializer(serializers.Serializer):
    username = serializers.CharField(max_length=32)
    password = serializers.CharField(min_length=6)
    email = serializers.EmailField(max_length=64)
    bj_username = serializers.CharField(max_length=32)
    hr_username = serializers.CharField(max_length=32)
    captcha = serializers.CharField()
Ejemplo n.º 5
0
class JudgeServerHeartbeatSerializer(serializers.Serializer):
    hostname = serializers.CharField(max_length=128)
    judger_version = serializers.CharField(max_length=32)
    cpu_core = serializers.IntegerField(min_value=1)
    memory = serializers.FloatField(min_value=0, max_value=100)
    cpu = serializers.FloatField(min_value=0, max_value=100)
    action = serializers.ChoiceField(choices=("heartbeat", ))
    service_url = serializers.CharField(max_length=256)
Ejemplo n.º 6
0
class CreateEditForumPostSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    title = serializers.CharField(max_length=64)
    sort = serializers.IntegerField(min_value=0, max_value=20)
    content = serializers.CharField(max_length=1024 * 1024 * 8)
    is_top = serializers.BooleanField()
    is_nice = serializers.BooleanField()
    is_light = serializers.BooleanField()
Ejemplo n.º 7
0
class ContestAdminSerializer(serializers.ModelSerializer):
    created_by = UsernameSerializer()
    status = serializers.CharField()
    contest_type = serializers.CharField()

    class Meta:
        model = Contest
        fields = "__all__"
Ejemplo n.º 8
0
class JoinCourseRequestSerializer(serializers.ModelSerializer):
    request_username = serializers.CharField(source='user.username')
    request_sno = serializers.CharField(source='user.sno')
    request_real_name = serializers.CharField(
        source='user.userprofile.real_name')

    class Meta:
        model = JoinCourseRequest
        exclude = ("user", "course")
Ejemplo n.º 9
0
class EditSMTPConfigSerializer(serializers.Serializer):
    server = serializers.CharField(max_length=128)
    port = serializers.IntegerField(default=25)
    email = serializers.CharField(max_length=256)
    password = serializers.CharField(max_length=128,
                                     required=False,
                                     allow_null=True,
                                     allow_blank=True)
    tls = serializers.BooleanField()
Ejemplo n.º 10
0
class CreateEditWebsiteConfigSerializer(serializers.Serializer):
    website_base_url = serializers.CharField(max_length=128)
    website_name = serializers.CharField(max_length=64)
    website_name_shortcut = serializers.CharField(max_length=64)
    website_footer = serializers.CharField(max_length=1024 * 1024)
    allow_register = serializers.BooleanField()
    submission_list_show_all = serializers.BooleanField()
    forum_sort = serializers.ListField(allow_empty=False)
    allow_forum_post = serializers.BooleanField()
    allow_forum_reply = serializers.BooleanField()
Ejemplo n.º 11
0
class CreateConetestSeriaizer(serializers.Serializer):
    title = serializers.CharField(max_length=128)
    description = serializers.CharField()
    start_time = serializers.DateTimeField()
    end_time = serializers.DateTimeField()
    rule_type = serializers.ChoiceField(choices=[ContestRuleType.ACM, ContestRuleType.OI])
    password = serializers.CharField(allow_blank=True, max_length=32)
    visible = serializers.BooleanField()
    real_time_rank = serializers.BooleanField()
    allowed_ip_ranges = serializers.ListField(child=serializers.CharField(max_length=32), allow_empty=True)
Ejemplo n.º 12
0
class EditConetestSeriaizer(serializers.Serializer):
    id = serializers.IntegerField()
    title = serializers.CharField(max_length=128)
    description = serializers.CharField()
    start_time = serializers.DateTimeField()
    end_time = serializers.DateTimeField()
    password = serializers.CharField(allow_blank=True, allow_null=True, max_length=32)
    visible = serializers.BooleanField()
    real_time_rank = serializers.BooleanField()
    allowed_ip_ranges = serializers.ListField(child=serializers.CharField(max_length=32))
Ejemplo n.º 13
0
class CreateOrEditProblemSerializer(serializers.Serializer):
    _id = serializers.CharField(max_length=32,
                                allow_blank=True,
                                allow_null=True)
    title = serializers.CharField(max_length=1024)
    description = serializers.CharField()
    input_description = serializers.CharField()
    output_description = serializers.CharField()
    samples = serializers.ListField(child=CreateSampleSerializer(),
                                    allow_empty=False)
    test_case_id = serializers.CharField(max_length=32)
    test_case_score = serializers.ListField(
        child=CreateTestCaseScoreSerializer(), allow_empty=True)
    time_limit = serializers.IntegerField(min_value=1, max_value=1000 * 60)
    memory_limit = serializers.IntegerField(min_value=1, max_value=1024)
    languages = LanguageNameMultiChoiceField()
    # template = serializers.DictField(child=serializers.CharField(min_length=1))
    rule_type = serializers.ChoiceField(
        choices=[ProblemRuleType.ACM, ProblemRuleType.OI])
    io_mode = ProblemIOModeSerializer()
    spj = serializers.BooleanField(default=False)
    spj_language = SPJLanguageNameChoiceField(allow_blank=True,
                                              allow_null=True)
    spj_code = serializers.CharField(allow_blank=True, allow_null=True)
    spj_compile_ok = serializers.BooleanField(default=False)
    visible = serializers.BooleanField()
    # difficulty = serializers.ChoiceField(choices=Difficulty.choices())
    tags = serializers.ListField(child=serializers.CharField(max_length=32),
                                 allow_empty=False)
    # hint = serializers.CharField(allow_blank=True, allow_null=True)
    source = serializers.CharField(max_length=256,
                                   allow_blank=True,
                                   allow_null=True)
    share_submission = serializers.BooleanField()
Ejemplo n.º 14
0
class EditUserSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    username = serializers.CharField(max_length=32)
    real_name = serializers.CharField(max_length=32, allow_blank=True, allow_null=True)
    password = serializers.CharField(min_length=6, allow_blank=True, required=False, default=None)
    email = serializers.EmailField(max_length=64)
    admin_type = serializers.ChoiceField(choices=(AdminType.REGULAR_USER, AdminType.ADMIN, AdminType.SUPER_ADMIN))
    problem_permission = serializers.ChoiceField(choices=(ProblemPermission.NONE, ProblemPermission.OWN,
                                                          ProblemPermission.ALL))
    open_api = serializers.BooleanField()
    two_factor_auth = serializers.BooleanField()
    is_disabled = serializers.BooleanField()
Ejemplo n.º 15
0
class ProblemIOModeSerializer(serializers.Serializer):
    io_mode = serializers.ChoiceField(choices=ProblemIOMode.choices())
    input = serializers.CharField()
    output = serializers.CharField()

    def validate(self, attrs):
        if attrs["input"] == attrs["output"]:
            raise serializers.ValidationError("Invalid io mode")
        for item in (attrs["input"], attrs["output"]):
            if not re.match("^[a-zA-Z0-9.]+$", item):
                raise serializers.ValidationError("Invalid io file name format")
        return attrs
Ejemplo n.º 16
0
class ContestAdminSerializer(serializers.ModelSerializer):
    created_by = UsernameSerializer()
    status = serializers.CharField()
    contest_type = serializers.CharField()

    course = serializers.BooleanField()
    # 课程号
    course_num = serializers.CharField()
    # 老师
    teacher = serializers.CharField()

    class Meta:
        model = Contest
        fields = "__all__"
Ejemplo n.º 17
0
class UserRegisterSerializer(serializers.Serializer):
    username = serializers.CharField(max_length=32)
    password = serializers.CharField(min_length=6)
    email = serializers.EmailField(max_length=64)

    # captcha = serializers.CharField()

    def validate(self, data):
        input_data = data
        data["username"] = data["username"].lower()
        data["email"] = data["email"].lower()
        if User.objects.filter(username=data["username"]).exists():
            raise serializers.ValidationError("Username already exists")
        if User.objects.filter(email=data["email"]).exists():
            raise serializers.ValidationError("Email already exists")
        return input_data
Ejemplo n.º 18
0
class ImportProblemSerializer(serializers.Serializer):
    display_id = serializers.CharField(max_length=128)
    title = serializers.CharField(max_length=128)
    description = FormatValueSerializer()
    input_description = FormatValueSerializer()
    output_description = FormatValueSerializer()
    hint = FormatValueSerializer()
    test_case_score = serializers.ListField(child=TestCaseScoreSerializer(), allow_null=True)
    time_limit = serializers.IntegerField(min_value=1, max_value=60000)
    memory_limit = serializers.IntegerField(min_value=1, max_value=10240)
    samples = serializers.ListField(child=CreateSampleSerializer())
    template = serializers.DictField(child=TemplateSerializer())
    spj = SPJSerializer(allow_null=True)
    rule_type = serializers.ChoiceField(choices=ProblemRuleType.choices())
    source = serializers.CharField(max_length=200, allow_blank=True, allow_null=True)
    answers = serializers.ListField(child=AnswerSerializer())
    tags = serializers.ListField(child=serializers.CharField())
Ejemplo n.º 19
0
class EditUserProfileSerializer(serializers.Serializer):
    real_name = serializers.CharField(max_length=32,
                                      allow_null=True,
                                      required=False)
    avatar = serializers.CharField(max_length=256,
                                   allow_blank=True,
                                   required=False)
    blog = serializers.URLField(max_length=256,
                                allow_blank=True,
                                required=False)
    mood = serializers.CharField(max_length=256,
                                 allow_blank=True,
                                 required=False)
    github = serializers.CharField(max_length=64,
                                   allow_blank=True,
                                   required=False)
    school = serializers.CharField(max_length=64,
                                   allow_blank=True,
                                   required=False)
    major = serializers.CharField(max_length=64,
                                  allow_blank=True,
                                  required=False)
    language = serializers.CharField(max_length=32,
                                     allow_blank=True,
                                     required=False)
Ejemplo n.º 20
0
class CreateOrEditCourseSerializer(serializers.Serializer):
    title = serializers.CharField(max_length=1024)
    charpter = serializers.CharField(max_length=32)
    section = serializers.CharField(max_length=32)
    content = serializers.CharField()
    on_class_problems = serializers.ListField(child=serializers.CharField(max_length=32), allow_empty=True, default=[])
    after_class_problems = serializers.ListField(child=serializers.CharField(max_length=32), allow_empty=True, default=[])
Ejemplo n.º 21
0
class FPSProblemSerializer(serializers.Serializer):
    class UnitSerializer(serializers.Serializer):
        unit = serializers.ChoiceField(choices=["MB", "s", "ms"])
        value = serializers.IntegerField(min_value=1, max_value=60000)

    title = serializers.CharField(max_length=128)
    description = serializers.CharField()
    input = serializers.CharField()
    output = serializers.CharField()
    hint = serializers.CharField(allow_blank=True, allow_null=True)
    time_limit = UnitSerializer()
    memory_limit = UnitSerializer()
    samples = serializers.ListField(child=CreateSampleSerializer())
    source = serializers.CharField(max_length=200,
                                   allow_blank=True,
                                   allow_null=True)
    spj = SPJSerializer(allow_null=True)
    template = serializers.ListField(child=serializers.DictField(),
                                     allow_empty=True,
                                     allow_null=True)
    append = serializers.ListField(child=serializers.DictField(),
                                   allow_empty=True,
                                   allow_null=True)
    prepend = serializers.ListField(child=serializers.DictField(),
                                    allow_empty=True,
                                    allow_null=True)
Ejemplo n.º 22
0
class CreateAnnouncementSerializer(serializers.Serializer):
    title = serializers.CharField(max_length=64)
    content = serializers.CharField(max_length=1024 * 1024 * 8)
    visible = serializers.BooleanField()
    istop = serializers.BooleanField()
Ejemplo n.º 23
0
class EditAnnouncementSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    title = serializers.CharField(max_length=64)
    content = serializers.CharField(max_length=1024 * 1024 * 8)
    visible = serializers.BooleanField()
    istop = serializers.BooleanField()
Ejemplo n.º 24
0
class CreateEditForumReplySerializer(serializers.Serializer):
    fa_id = serializers.IntegerField()
    content = serializers.CharField(max_length=1024 * 1024 * 8)
Ejemplo n.º 25
0
class FileDownloadSerializer(serializers.Serializer):
    file_type = serializers.CharField(max_length=1024)
    file_name = serializers.CharField(max_length=1024)
Ejemplo n.º 26
0
class CreateSubmissionSerializer(serializers.Serializer):
    problem_id = serializers.IntegerField()
    language = LanguageNameChoiceField()
    code = serializers.CharField(max_length=1024 * 1024)
    contest_id = serializers.IntegerField(required=False)
    captcha = serializers.CharField(required=False)
Ejemplo n.º 27
0
class ShareSubmissionSerializer(serializers.Serializer):
    id = serializers.CharField()
    shared = serializers.BooleanField()
Ejemplo n.º 28
0
class ContestPasswordVerifySerializer(serializers.Serializer):
    contest_id = serializers.IntegerField()
    password = serializers.CharField(max_length=30, required=True)
Ejemplo n.º 29
0
class EditContestAnnouncementSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    title = serializers.CharField(max_length=128, required=False)
    content = serializers.CharField(required=False, allow_blank=True)
    visible = serializers.BooleanField(required=False)
Ejemplo n.º 30
0
class CreateContestAnnouncementSerializer(serializers.Serializer):
    contest_id = serializers.IntegerField()
    title = serializers.CharField(max_length=128)
    content = serializers.CharField()
    visible = serializers.BooleanField()