2017-12-01 17:19:31 +08:00
|
|
|
from utils.api import serializers
|
2016-11-19 13:47:59 +08:00
|
|
|
|
2017-10-02 03:54:34 +08:00
|
|
|
from .models import JudgeServer
|
2016-11-19 13:47:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
class EditSMTPConfigSerializer(serializers.Serializer):
|
|
|
|
server = serializers.CharField(max_length=128)
|
|
|
|
port = serializers.IntegerField(default=25)
|
2018-05-17 01:22:05 +08:00
|
|
|
email = serializers.CharField(max_length=256)
|
2016-11-19 13:47:59 +08:00
|
|
|
password = serializers.CharField(max_length=128, required=False, allow_null=True, allow_blank=True)
|
|
|
|
tls = serializers.BooleanField()
|
|
|
|
|
|
|
|
|
|
|
|
class CreateSMTPConfigSerializer(EditSMTPConfigSerializer):
|
|
|
|
password = serializers.CharField(max_length=128)
|
2017-01-23 16:25:14 +08:00
|
|
|
|
2016-11-19 13:47:59 +08:00
|
|
|
|
|
|
|
class TestSMTPConfigSerializer(serializers.Serializer):
|
|
|
|
email = serializers.EmailField()
|
2017-01-23 16:25:14 +08:00
|
|
|
|
2016-11-19 13:47:59 +08:00
|
|
|
|
|
|
|
class CreateEditWebsiteConfigSerializer(serializers.Serializer):
|
2017-10-02 03:54:34 +08:00
|
|
|
website_base_url = serializers.CharField(max_length=128)
|
2017-10-02 05:16:14 +08:00
|
|
|
website_name = serializers.CharField(max_length=64)
|
|
|
|
website_name_shortcut = serializers.CharField(max_length=64)
|
|
|
|
website_footer = serializers.CharField(max_length=1024 * 1024)
|
2016-11-19 13:47:59 +08:00
|
|
|
allow_register = serializers.BooleanField()
|
|
|
|
submission_list_show_all = serializers.BooleanField()
|
|
|
|
|
|
|
|
|
2016-11-20 19:18:25 +08:00
|
|
|
class JudgeServerSerializer(serializers.ModelSerializer):
|
2017-01-24 13:22:12 +08:00
|
|
|
status = serializers.CharField()
|
2016-11-20 19:18:25 +08:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = JudgeServer
|
2017-10-02 03:54:34 +08:00
|
|
|
fields = "__all__"
|
2016-11-20 19:18:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
class JudgeServerHeartbeatSerializer(serializers.Serializer):
|
2017-10-02 05:16:14 +08:00
|
|
|
hostname = serializers.CharField(max_length=128)
|
|
|
|
judger_version = serializers.CharField(max_length=32)
|
2016-11-20 19:18:25 +08:00
|
|
|
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", ))
|
2017-12-24 12:08:56 +08:00
|
|
|
service_url = serializers.CharField(max_length=256)
|
2017-12-24 12:10:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
class EditJudgeServerSerializer(serializers.Serializer):
|
|
|
|
id = serializers.IntegerField()
|
|
|
|
is_disabled = serializers.BooleanField()
|