From c15c01448a2b22c51a9ba4596531dbcaa14372fd Mon Sep 17 00:00:00 2001 From: detraz Date: Mon, 15 Oct 2018 00:58:46 +0200 Subject: [PATCH] Remplace trnoname par de meilleurs affichages --- machines/models.py | 5 +++++ machines/templates/machines/aff_machines.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/machines/models.py b/machines/models.py index 4caca48a..412e3750 100644 --- a/machines/models.py +++ b/machines/models.py @@ -213,6 +213,11 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model): interface_parent__machine=self ).values_list('name', flat=True).distinct() + @cached_property + def get_name(self): + """Return a name : user provided name or first interface name""" + return self.name or self.short_name + @cached_property def all_complete_names(self): """Renvoie tous les tls complets de la machine""" diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index bd65fc76..60e1a57a 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -52,7 +52,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% trans "No name" as tr_no_name %} {% trans "View the profile" as tr_view_the_profile %} - {{ machine.name|default:'tr_no_name' }} + {{ machine.get_name|default:'tr_no_name' }} {{ machine.user }}