Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit ee79e21e authored by chirac's avatar chirac Committed by Levy--Falk Hugo

Finition, gestion du renvoie du profil par défaut du port

parent bac18a26
......@@ -262,9 +262,9 @@ def search_single_word(word, filters, user,
) | Q(
) | Q(
) | Q(
) | Q(
......@@ -413,19 +413,29 @@ class Port(AclMixin, RevMixin, models.Model):
def get_port_profil(self):
"""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
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:
return custom_profil
return self.custom_profil
elif self.related:
return PortProfil.objects.get(profil_default='uplink')
return profil_or_nothing('uplink')
elif self.machine_interface:
if isinstance(self.machine_interface.machine, AccessPoint):
return PortProfil.objects.get(profil_default='access_point')
if hasattr(self.machine_interface.machine, 'accesspoint'):
return profil_or_nothing('access_point')
return PortProfil.objects.get(profil_default='asso_machine')
return profil_or_nothing('asso_machine')
elif self.room:
return PortProfil.objects.get(profil_default='room')
return profil_or_nothing('room')
return PortProfil.objects.get(profil_default='nothing')
return profil_or_nothing('nothing')
def get_instance(cls, portid, *_args, **kwargs):
......@@ -70,7 +70,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% acl_end %}
{% endif %}
<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 class="text-right">
{% history_button port %}
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