show upstream in node uplink

This commit is contained in:
Laura Klünder 2024-03-30 19:58:21 +01:00
parent b84cd059df
commit 9da37855c0
3 changed files with 18 additions and 5 deletions

View file

@ -16,9 +16,13 @@
<strong>Uplink:</strong>
{% with uplink=node.get_uplink %}
{% if uplink %}
<a href="{% url "mesh.node.detail" pk=uplink.node_id %}">{{ uplink.node }}</a>
{% mesh_node uplink.node %}<br>
{% if uplink.node == node %}
<em>(direct)</em>
{% trans '(is an uplink)' %}
{% elif node.upstream %}
{% trans 'via:' %} {% mesh_node node.upstream %}
{% else %}
{% trans '(direct)' %}
{% endif %}
{% else %}
<em>offline</em>

View file

@ -1,5 +1,6 @@
{% extends 'mesh/base.html' %}
{% load i18n %}
{% load mesh_node %}
{% block heading %}{% trans 'Mesh Nodes' %}{% endblock %}
@ -45,7 +46,14 @@
<td>
{% with uplink=node.get_uplink %}
{% if uplink %}
<a href="{% url "mesh.node.detail" pk=uplink.node_id %}">{{ node.uplink.node }}</a>
{% mesh_node uplink.node %}<br>
{% if uplink.node == node %}
{% trans '(is an uplink)' %}
{% elif node.upstream %}
{% trans 'via:' %} {% mesh_node node.upstream %}
{% else %}
{% trans '(direct)' %}
{% endif %}
{% else %}
<em>offline</em>
{% endif %}

View file

@ -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):