mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
9627 test fixes
This commit is contained in:
parent
f509ca4e5e
commit
226312631a
@ -27,7 +27,7 @@ class NumericRangeArraySerializer(serializers.BaseSerializer):
|
|||||||
return string_to_range_array(data)
|
return string_to_range_array(data)
|
||||||
|
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
return ranges_to_string(data)
|
return ranges_to_string(instance)
|
||||||
|
|
||||||
|
|
||||||
class VLANGroupSerializer(NetBoxModelSerializer):
|
class VLANGroupSerializer(NetBoxModelSerializer):
|
||||||
@ -46,7 +46,7 @@ class VLANGroupSerializer(NetBoxModelSerializer):
|
|||||||
|
|
||||||
# Related object counts
|
# Related object counts
|
||||||
vlan_count = RelatedObjectCountField('vlans')
|
vlan_count = RelatedObjectCountField('vlans')
|
||||||
vlan_id_ranges = NumericRangeArraySerializer()
|
vlan_id_ranges = NumericRangeArraySerializer(required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = VLANGroup
|
model = VLANGroup
|
||||||
|
@ -140,7 +140,7 @@ def ranges_to_string(ranges):
|
|||||||
For example:
|
For example:
|
||||||
[1-100, 200-300] => "1-100, 200-300"
|
[1-100, 200-300] => "1-100, 200-300"
|
||||||
"""
|
"""
|
||||||
return ', '.join([f"{val.lower}-{val.upper}" for val in value])
|
return ', '.join([f"{val.lower}-{val.upper}" for val in ranges])
|
||||||
|
|
||||||
|
|
||||||
def string_to_range_array(value):
|
def string_to_range_array(value):
|
||||||
|
Loading…
Reference in New Issue
Block a user