feat: 修改route serializer
This commit is contained in:
parent
15c4e195f3
commit
b2664ca81b
|
@ -134,7 +134,7 @@ class RoutePackSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RoutePack
|
model = RoutePack
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
read_only_fields = EXCLUDE_FIELDS + ['state']
|
read_only_fields = EXCLUDE_FIELDS + ['state', 'ticket']
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
if validated_data['material'] != instance.material:
|
if validated_data['material'] != instance.material:
|
||||||
|
@ -161,6 +161,8 @@ class RouteSerializer(CustomModelSerializer):
|
||||||
read_only_fields = EXCLUDE_FIELDS
|
read_only_fields = EXCLUDE_FIELDS
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
if 'routepack' in attrs:
|
||||||
|
attrs['material'] = attrs['routepack'].material
|
||||||
if 'mgroup' in attrs and attrs['mgroup']:
|
if 'mgroup' in attrs and attrs['mgroup']:
|
||||||
attrs['process'] = attrs['mgroup'].process
|
attrs['process'] = attrs['mgroup'].process
|
||||||
if attrs.get('process', None) is None:
|
if attrs.get('process', None) is None:
|
||||||
|
|
Loading…
Reference in New Issue