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