mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 04:43:10 +00:00
Fix #131
This commit is contained in:
parent
7cafc9e99d
commit
2e6df9c235
2 changed files with 6 additions and 10 deletions
|
@ -87,15 +87,7 @@ class EditPortForm(FormRevMixin, ModelForm):
|
|||
self.fields['machine_interface'].queryset = (
|
||||
Interface.objects.all().select_related('domain__extension')
|
||||
)
|
||||
self.fields['related'].queryset = (
|
||||
Port.objects.all()
|
||||
.prefetch_related(Prefetch(
|
||||
'switch__interface_set',
|
||||
queryset=(Interface.objects
|
||||
.select_related('ipv4__ip_type__extension')
|
||||
.select_related('domain__extension'))
|
||||
))
|
||||
)
|
||||
self.fields['related'].queryset = Port.objects.all().prefetch_related('switch__machine_ptr__interface_set__domain__extension')
|
||||
|
||||
|
||||
class AddPortForm(FormRevMixin, ModelForm):
|
||||
|
|
|
@ -274,8 +274,12 @@ class Switch(AclMixin, Machine):
|
|||
""" Returns the 'main' interface of the switch """
|
||||
return self.interface_set.first()
|
||||
|
||||
@cached_property
|
||||
def get_name(self):
|
||||
return self.name or self.main_interface().domain.name
|
||||
|
||||
def __str__(self):
|
||||
return str(self.main_interface())
|
||||
return str(self.get_name)
|
||||
|
||||
|
||||
class ModelSwitch(AclMixin, RevMixin, models.Model):
|
||||
|
|
Loading…
Reference in a new issue