-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serializers.py
64 lines (58 loc) · 3.82 KB
/
serializers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from rest_framework import serializers
from .models import ListModel
from utils import datasolve
class BinsizeGetSerializer(serializers.ModelSerializer):
bin_size = serializers.CharField(read_only=True, required=False)
bin_size_w = serializers.FloatField(read_only=True, required=False)
bin_size_d = serializers.FloatField(read_only=True, required=False)
bin_size_h = serializers.FloatField(read_only=True, required=False)
creater = serializers.CharField(read_only=True, required=False)
create_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
update_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
class Meta:
model = ListModel
exclude = ['openid', 'is_delete', ]
read_only_fields = ['id', ]
class BinsizePostSerializer(serializers.ModelSerializer):
openid = serializers.CharField(read_only=False, required=False, validators=[datasolve.openid_validate])
bin_size = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
bin_size_w = serializers.FloatField(read_only=False, required=True, validators=[datasolve.data_validate])
bin_size_d = serializers.FloatField(read_only=False, required=True, validators=[datasolve.data_validate])
bin_size_h = serializers.FloatField(read_only=False, required=True, validators=[datasolve.data_validate])
creater = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
class Meta:
model = ListModel
exclude = ['is_delete', ]
read_only_fields = ['id', 'create_time', 'update_time', ]
class BinsizeUpdateSerializer(serializers.ModelSerializer):
bin_size = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
bin_size_w = serializers.FloatField(read_only=False, required=True, validators=[datasolve.data_validate])
bin_size_d = serializers.FloatField(read_only=False, required=True, validators=[datasolve.data_validate])
bin_size_h = serializers.FloatField(read_only=False, required=True, validators=[datasolve.data_validate])
creater = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
class Meta:
model = ListModel
exclude = ['openid', 'is_delete', ]
read_only_fields = ['id', 'create_time', 'update_time', ]
class BinsizePartialUpdateSerializer(serializers.ModelSerializer):
bin_size = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
bin_size_w = serializers.FloatField(read_only=False, required=False, validators=[datasolve.data_validate])
bin_size_d = serializers.FloatField(read_only=False, required=False, validators=[datasolve.data_validate])
bin_size_h = serializers.FloatField(read_only=False, required=False, validators=[datasolve.data_validate])
creater = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
class Meta:
model = ListModel
exclude = ['openid', 'is_delete', ]
read_only_fields = ['id', 'create_time', 'update_time', ]
class FileRenderSerializer(serializers.ModelSerializer):
bin_size = serializers.CharField(read_only=False, required=False)
bin_size_w = serializers.FloatField(read_only=False, required=False)
bin_size_d = serializers.FloatField(read_only=False, required=False)
bin_size_h = serializers.FloatField(read_only=False, required=False)
creater = serializers.CharField(read_only=False, required=False)
create_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
update_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
class Meta:
model = ListModel
ref_name = 'BinSizeFileRenderSerializer'
exclude = ['openid', 'is_delete', ]