fix: quastat update serializer
This commit is contained in:
parent
00677d100b
commit
887976363b
|
@ -19,11 +19,12 @@ class QuaStatSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = QuaStat
|
model = QuaStat
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
read_only_fields = EXCLUDE_FIELDS + ['type', 'rate_pass', 'year_s', 'month_s', 'day_s', 'belong_dept']
|
read_only_fields = EXCLUDE_FIELDS + ['belong_dept']
|
||||||
extra_kwargs = {'val_avg': {'required': True, 'allow_null': False}, 'num_test':{'required': True, 'allow_null': False}, 'num_ok': {'required': True, 'allow_null': False}}
|
extra_kwargs = {'val_avg': {'required': True, 'allow_null': False}, 'num_test':{'required': True, 'allow_null': False}, 'num_ok': {'required': True, 'allow_null': False}}
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
attrs['rate_pass'] = attrs['num_ok']/attrs['num_test']
|
attrs['rate_pass'] = attrs['num_ok']/attrs['num_test']
|
||||||
|
attrs['belong_dept'] = attrs['sflog'].mgroup.belong_dept
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
class QuaStatUpdateSerializer(CustomModelSerializer):
|
class QuaStatUpdateSerializer(CustomModelSerializer):
|
||||||
|
@ -34,7 +35,7 @@ class QuaStatUpdateSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = QuaStat
|
model = QuaStat
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
read_only_fields = EXCLUDE_FIELDS + ['type', 'rate_pass', 'year_s', 'month_s', 'day_s', 'belong_dept', 'sflog', 'material', 'testitem']
|
read_only_fields = EXCLUDE_FIELDS + ['belong_dept', 'sflog', 'material', 'testitem']
|
||||||
extra_kwargs = {'val_avg': {'required': True, 'allow_null': False}, 'num_test':{'required': True, 'allow_null': False}, 'num_ok': {'required': True, 'allow_null': False}}
|
extra_kwargs = {'val_avg': {'required': True, 'allow_null': False}, 'num_test':{'required': True, 'allow_null': False}, 'num_ok': {'required': True, 'allow_null': False}}
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
|
Loading…
Reference in New Issue