From ce87de1dfb87c80ed320ff11fc7f4f63e81d4aca Mon Sep 17 00:00:00 2001 From: Fioddor Superconcentrado Date: Wed, 16 Dec 2020 10:34:00 +0100 Subject: [PATCH] networks: Hide deactivate/remove buttons for primary connections Helps: #1962. Signed-off-by: Fioddor Superconcentrado Reviewed-by: Sunil Mohan Adapa --- .../networks/templates/connections_list.html | 29 ++++++++++--------- plinth/network.py | 7 ++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/plinth/modules/networks/templates/connections_list.html b/plinth/modules/networks/templates/connections_list.html index 987786794..50b43a119 100644 --- a/plinth/modules/networks/templates/connections_list.html +++ b/plinth/modules/networks/templates/connections_list.html @@ -53,12 +53,14 @@ {% if connection.is_active %} -
- {% csrf_token %} - -
+ {% if not connection.primary %} +
+ {% csrf_token %} + +
+ {% endif %} {% else %}
@@ -68,13 +70,14 @@
{% endif %} - - - + {% if not connection.primary %} + + + + {% endif %} {% endfor %} diff --git a/plinth/network.py b/plinth/network.py index 1a79adfff..1c07efec9 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -217,8 +217,10 @@ def _get_wifi_channel_from_frequency(frequency): def get_connection_list(): """Get a list of active and available connections.""" - active_uuids = [] client = get_nm_client() + primary_connection = client.get_primary_connection() + + active_uuids = [] for connection in client.get_active_connections(): active_uuids.append(connection.get_uuid()) @@ -241,6 +243,9 @@ def get_connection_list(): 'type': connection_type, 'type_name': connection_type_name, 'is_active': connection.get_uuid() in active_uuids, + 'primary': + (primary_connection + and primary_connection.get_uuid() == connection.get_uuid()), 'zone': zone, }) connections.sort(key=lambda connection: connection['is_active'],