Skip to content

Commit b92e345

Browse files
committed
Fixes #8077: Fix exception when attaching image to location, circuit, or power panel
1 parent b6ff553 commit b92e345

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

docs/release-notes/version-3.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
* [#7674](https://github.com/netbox-community/netbox/issues/7674) - Fix inadvertent application of device type context to virtual machines
1313
* [#8074](https://github.com/netbox-community/netbox/issues/8074) - Ordering VMs by name should reference naturalized value
14+
* [#8077](https://github.com/netbox-community/netbox/issues/8077) - Fix exception when attaching image to location, circuit, or power panel
1415
* [#8078](https://github.com/netbox-community/netbox/issues/8078) - Add missing wireless models to `lsmodels()` in `nbshell`
1516
* [#8079](https://github.com/netbox-community/netbox/issues/8079) - Fix validation of LLDP neighbors when connected device has an asset tag
1617

netbox/extras/api/serializers.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,7 @@ def validate(self, data):
170170

171171
@swagger_serializer_method(serializer_or_field=serializers.DictField)
172172
def get_parent(self, obj):
173-
174-
# Static mapping of models to their nested serializers
175-
if isinstance(obj.parent, Device):
176-
serializer = NestedDeviceSerializer
177-
elif isinstance(obj.parent, Rack):
178-
serializer = NestedRackSerializer
179-
elif isinstance(obj.parent, Site):
180-
serializer = NestedSiteSerializer
181-
else:
182-
raise Exception("Unexpected type of parent object for ImageAttachment")
183-
173+
serializer = get_serializer_for_model(obj.parent, prefix='Nested')
184174
return serializer(obj.parent, context={'request': self.context['request']}).data
185175

186176

0 commit comments

Comments
 (0)