mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
11432 make device field on interface read-only on api edit call
This commit is contained in:
parent
53f6b9f17a
commit
e72a7fa401
@ -909,13 +909,16 @@ class InterfaceSerializer(NetBoxModelSerializer, CabledObjectSerializer, Connect
|
|||||||
|
|
||||||
return super().validate(data)
|
return super().validate(data)
|
||||||
|
|
||||||
def get_extra_kwargs(self):
|
def get_fields(self, *args, **kwargs):
|
||||||
if self.instance:
|
fields = super().get_fields(*args, **kwargs)
|
||||||
kwargs = {'device': {'read_only': True}}
|
request = self.context.get('request', None)
|
||||||
else:
|
view = self.context.get('view', None)
|
||||||
kwargs = {}
|
|
||||||
|
|
||||||
return kwargs
|
# get_extra_kwargs doesn't work if field explicitly declared on serializer...
|
||||||
|
if (self.instance):
|
||||||
|
fields['device'].read_only = True
|
||||||
|
|
||||||
|
return fields
|
||||||
|
|
||||||
|
|
||||||
class RearPortSerializer(NetBoxModelSerializer, CabledObjectSerializer):
|
class RearPortSerializer(NetBoxModelSerializer, CabledObjectSerializer):
|
||||||
|
Loading…
Reference in New Issue
Block a user