From 9da37855c0cb7660c335d46b32aa085a648c7d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Sat, 30 Mar 2024 19:58:21 +0100 Subject: [PATCH] show upstream in node uplink --- src/c3nav/mesh/templates/mesh/node_detail.html | 8 ++++++-- src/c3nav/mesh/templates/mesh/nodes.html | 10 +++++++++- src/c3nav/mesh/views/nodes.py | 5 +++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/c3nav/mesh/templates/mesh/node_detail.html b/src/c3nav/mesh/templates/mesh/node_detail.html index a51d4771..adc3b79b 100644 --- a/src/c3nav/mesh/templates/mesh/node_detail.html +++ b/src/c3nav/mesh/templates/mesh/node_detail.html @@ -16,9 +16,13 @@ Uplink: {% with uplink=node.get_uplink %} {% if uplink %} - {{ uplink.node }} + {% mesh_node uplink.node %}
{% if uplink.node == node %} - (direct) + {% trans '(is an uplink)' %} + {% elif node.upstream %} + {% trans 'via:' %} {% mesh_node node.upstream %} + {% else %} + {% trans '(direct)' %} {% endif %} {% else %} offline diff --git a/src/c3nav/mesh/templates/mesh/nodes.html b/src/c3nav/mesh/templates/mesh/nodes.html index c2bce1ca..891e4d4d 100644 --- a/src/c3nav/mesh/templates/mesh/nodes.html +++ b/src/c3nav/mesh/templates/mesh/nodes.html @@ -1,5 +1,6 @@ {% extends 'mesh/base.html' %} {% load i18n %} +{% load mesh_node %} {% block heading %}{% trans 'Mesh Nodes' %}{% endblock %} @@ -45,7 +46,14 @@ {% with uplink=node.get_uplink %} {% if uplink %} - {{ node.uplink.node }} + {% mesh_node uplink.node %}
+ {% if uplink.node == node %} + {% trans '(is an uplink)' %} + {% elif node.upstream %} + {% trans 'via:' %} {% mesh_node node.upstream %} + {% else %} + {% trans '(direct)' %} + {% endif %} {% else %} offline {% endif %} diff --git a/src/c3nav/mesh/views/nodes.py b/src/c3nav/mesh/views/nodes.py index fcd765a6..b4be562f 100644 --- a/src/c3nav/mesh/views/nodes.py +++ b/src/c3nav/mesh/views/nodes.py @@ -15,7 +15,8 @@ class NodeListView(MeshControlMixin, ListView): context_object_name = "nodes" def get_queryset(self): - return super().get_queryset().prefetch_last_messages().prefetch_firmwares().prefetch_ranging_beacon() + return (super().get_queryset().prefetch_last_messages().prefetch_firmwares() + .prefetch_ranging_beacon().select_related("upstream")) class NodeDetailView(MeshControlMixin, DetailView): @@ -25,7 +26,7 @@ class NodeDetailView(MeshControlMixin, DetailView): context_object_name = "node" def get_queryset(self): - return super().get_queryset().prefetch_last_messages().prefetch_firmwares() + return super().get_queryset().prefetch_last_messages().prefetch_firmwares().select_related("upstream") class NodeEditView(MeshControlMixin, SuccessMessageMixin, UpdateView):