Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

Commit 3ce73a7a authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Fix divers sur la creation de port

parent 02240a8f
......@@ -80,9 +80,10 @@ class EditPortForm(ModelForm):
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
super(EditPortForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields['machine_interface'].queryset = Interface.objects.all()\
.select_related('domain__extension')
.select_related('domain__extension')
self.fields['related'].queryset = Port.objects.all()\
.select_related('switch__domain__extension')\
.select_related('switch')\
.prefetch_related('switch__interface_set__domain__extension')\
.order_by('switch', 'port')
......@@ -97,9 +98,10 @@ class AddPortForm(ModelForm):
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
super(AddPortForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields['machine_interface'].queryset = Interface.objects.all()\
.select_related('domain__extension')
.select_related('domain__extension')
self.fields['related'].queryset = Port.objects.all()\
.select_related('switch__domain__extension')\
.select_related('switch')\
.prefetch_related('switch__interface_set__domain__extension')\
.order_by('switch', 'port')
......
......@@ -263,6 +263,9 @@ class Switch(Machine):
except IntegrityError:
ValidationError("Création d'un port existant.")
def __str__(self):
return str(self.interface_set.first())
class ModelSwitch(models.Model):
"""Un modèle (au sens constructeur) de switch"""
......@@ -416,11 +419,11 @@ class Port(models.Model):
def get_instance(port_id, *args, **kwargs):
return Port.objects\
.select_related('switch__domain__extension')\
.select_related('machine_interface__domain__extension')\
.select_related('machine_interface__switch')\
.select_related('machine_interface__machine__switch')\
.select_related('room')\
.select_related('related')\
.prefetch_related('switch__interface_set__domain__extension')\
.get(pk=port_id)
def can_create(user_request, *args, **kwargs):
......
......@@ -46,7 +46,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<td>
<a title="Configuer" href="{% url 'topologie:index-port' switch.pk %}">
{{switch.interface_set.first}}
{{switch}}
</a>
</td>
<td>{{switch.interface_set.first.ipv4}}</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment