mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 01:06:11 -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)
|
||||
|
||||
def get_extra_kwargs(self):
|
||||
if self.instance:
|
||||
kwargs = {'device': {'read_only': True}}
|
||||
else:
|
||||
kwargs = {}
|
||||
def get_fields(self, *args, **kwargs):
|
||||
fields = super().get_fields(*args, **kwargs)
|
||||
request = self.context.get('request', None)
|
||||
view = self.context.get('view', None)
|
||||
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user