1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #1141: Include VRF name and RD in form selections

This commit is contained in:
Jeremy Stretch
2017-06-14 15:00:27 -04:00
parent 4d7f9c42c8
commit 8bcd8c404d
2 changed files with 8 additions and 2 deletions

View File

@ -22,7 +22,7 @@ class VRFSerializer(CustomFieldModelSerializer):
class Meta:
model = VRF
fields = ['id', 'name', 'rd', 'tenant', 'enforce_unique', 'description', 'custom_fields']
fields = ['id', 'name', 'rd', 'tenant', 'enforce_unique', 'description', 'display_name', 'custom_fields']
class NestedVRFSerializer(serializers.ModelSerializer):

View File

@ -97,7 +97,7 @@ class VRF(CreatedUpdatedModel, CustomFieldModel):
verbose_name_plural = 'VRFs'
def __str__(self):
return self.name
return self.display_name or super(VRF, self).__str__()
def get_absolute_url(self):
return reverse('ipam:vrf', args=[self.pk])
@ -111,6 +111,12 @@ class VRF(CreatedUpdatedModel, CustomFieldModel):
self.description,
])
@property
def display_name(self):
if self.name and self.rd:
return "{} ({})".format(self.name, self.rd)
return None
@python_2_unicode_compatible
class RIR(models.Model):