mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Finition, gestion du renvoie du profil par défaut du port
This commit is contained in:
parent
447919a2af
commit
e6b8c5c899
3 changed files with 23 additions and 13 deletions
|
@ -262,9 +262,9 @@ def search_single_word(word, filters, user,
|
||||||
) | Q(
|
) | Q(
|
||||||
related__switch__interface__domain__name__icontains=word
|
related__switch__interface__domain__name__icontains=word
|
||||||
) | Q(
|
) | Q(
|
||||||
radius__icontains=word
|
custom_profil__name__icontains=word
|
||||||
) | Q(
|
) | Q(
|
||||||
vlan_force__name__icontains=word
|
custom_profil__profil_default__icontains=word
|
||||||
) | Q(
|
) | Q(
|
||||||
details__icontains=word
|
details__icontains=word
|
||||||
)
|
)
|
||||||
|
|
|
@ -409,19 +409,29 @@ class Port(AclMixin, RevMixin, models.Model):
|
||||||
@cached_property
|
@cached_property
|
||||||
def get_port_profil(self):
|
def get_port_profil(self):
|
||||||
"""Return the config profil for this port"""
|
"""Return the config profil for this port"""
|
||||||
|
def profil_or_nothing(profil):
|
||||||
|
port_profil = PortProfile.objects.filter(profil_default=profil).first()
|
||||||
|
if port_profil:
|
||||||
|
return port_profil
|
||||||
|
else:
|
||||||
|
nothing = PortProfile.objects.filter(profil_default='nothing').first()
|
||||||
|
if not nothing:
|
||||||
|
nothing = PortProfile.objects.create(profil_default='nothing', name='nothing', radius_type='NO')
|
||||||
|
return nothing
|
||||||
|
|
||||||
if self.custom_profil:
|
if self.custom_profil:
|
||||||
return custom_profil
|
return self.custom_profil
|
||||||
elif self.related:
|
elif self.related:
|
||||||
return PortProfil.objects.get(profil_default='uplink')
|
return profil_or_nothing('uplink')
|
||||||
elif self.machine_interface:
|
elif self.machine_interface:
|
||||||
if isinstance(self.machine_interface.machine, AccessPoint):
|
if hasattr(self.machine_interface.machine, 'accesspoint'):
|
||||||
return PortProfil.objects.get(profil_default='access_point')
|
return profil_or_nothing('access_point')
|
||||||
else:
|
else:
|
||||||
return PortProfil.objects.get(profil_default='asso_machine')
|
return profil_or_nothing('asso_machine')
|
||||||
elif self.room:
|
elif self.room:
|
||||||
return PortProfil.objects.get(profil_default='room')
|
return profil_or_nothing('room')
|
||||||
else:
|
else:
|
||||||
return PortProfil.objects.get(profil_default='nothing')
|
return profil_or_nothing('nothing')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_instance(cls, portid, *_args, **kwargs):
|
def get_instance(cls, portid, *_args, **kwargs):
|
||||||
|
|
|
@ -65,7 +65,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{% if not port.custom_profil %}Par défaut{% else %}{{port.custom_profil}}{% endif %}</td>
|
<td>{% if not port.custom_profil %}<u>Par défaut</u> : {% endif %}{{port.get_port_profil}}</td>
|
||||||
<td>{{ port.details }}</td>
|
<td>{{ port.details }}</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'port' port.pk %}">
|
<a class="btn btn-info btn-sm" role="button" title="Historique" href="{% url 'topologie:history' 'port' port.pk %}">
|
||||||
|
|
Loading…
Reference in a new issue