networks: Hide deactivate/remove buttons for primary connections

Helps: #1962.

Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Fioddor Superconcentrado 2020-12-16 10:34:00 +01:00 committed by Sunil Mohan Adapa
parent 012a9a0fc7
commit ce87de1dfb
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 22 additions and 14 deletions

View File

@ -53,12 +53,14 @@
<td class="connection-actions">
{% if connection.is_active %}
<form class="form form-action" method="post"
action="{% url 'networks:deactivate' connection.uuid %}">
{% csrf_token %}
<button type="submit" class="btn btn-default btn-sm">
{% trans "Deactivate" %}</button>
</form>
{% if not connection.primary %}
<form class="form form-action" method="post"
action="{% url 'networks:deactivate' connection.uuid %}">
{% csrf_token %}
<button type="submit" class="btn btn-default btn-sm">
{% trans "Deactivate" %}</button>
</form>
{% endif %}
{% else %}
<form class="form form-action" method="post"
action="{% url 'networks:activate' connection.uuid %}">
@ -68,13 +70,14 @@
</form>
{% endif %}
<a href="{% url 'networks:delete' connection.uuid %}"
class="btn btn-default btn-sm"
role="button"
title="{% blocktrans with name=connection.name %}Delete connection {{ name }}{% endblocktrans %}">
<span class="fa fa-trash-o"
aria-hidden="true"></span>
</a>
{% if not connection.primary %}
<a href="{% url 'networks:delete' connection.uuid %}"
class="btn btn-default btn-sm"
role="button"
title="{% blocktrans with name=connection.name %}Delete connection {{ name }}{% endblocktrans %}">
<span class="fa fa-trash-o" aria-hidden="true"></span>
</a>
{% endif %}
</td>
</tr>
{% endfor %}

View File

@ -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'],