From 66e19ff56e384de3bfdd6c823356b355b4dbd343 Mon Sep 17 00:00:00 2001 From: Jim Gregory Date: Fri, 18 Mar 2022 16:04:09 -0500 Subject: [PATCH] network: Fix showing wifi connection Viewing a wifi connection will cause a 500 error. To reproduce this issue, go to plinth/sys/networks/. If no wifi connections exist, add one use the "Add Connection" button. Then, click on the name of the wifi connection to view it. A 500 error is returned. This commit fixes this error so the normal "show connection" is returned. It also fixes a bytestring conversion error for the SSID and a blank value for "mode" on the page. Reviewed-by: Sunil Mohan Adapa --- plinth/modules/networks/templates/connection_show.html | 2 +- plinth/modules/networks/views.py | 3 ++- plinth/network.py | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plinth/modules/networks/templates/connection_show.html b/plinth/modules/networks/templates/connection_show.html index 9d6d63902..f1993d992 100644 --- a/plinth/modules/networks/templates/connection_show.html +++ b/plinth/modules/networks/templates/connection_show.html @@ -146,7 +146,7 @@
{% trans "Mode" %} - {{ device.wireless.mode_string }} + {{ connection.wireless.mode_string }}
{% endif %} {% if access_point.channel %} diff --git a/plinth/modules/networks/views.py b/plinth/modules/networks/views.py index 96a6437af..4dbe18bb8 100644 --- a/plinth/modules/networks/views.py +++ b/plinth/modules/networks/views.py @@ -187,7 +187,8 @@ def show(request, uuid): device, connection_status['wireless']['ssid']) connection_status['wireless'][ 'mode_string'] = WIRELESS_MODE_STRINGS.get( - connection['wireless']['mode'], connection['wireless']['mode']) + connection_status['wireless']['mode'], + connection_status['wireless']['mode']) return TemplateResponse( request, 'connection_show.html', { diff --git a/plinth/network.py b/plinth/network.py index e4c8d1222..ac6296490 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -111,7 +111,9 @@ def get_status_from_connection(connection): if status['type'] == '802-11-wireless': setting_wireless = connection.get_setting_wireless() - status['wireless']['ssid'] = setting_wireless.get_ssid().get_data() + status['wireless']['ssid'] = setting_wireless.get_ssid().get_data( + ).decode() + status['wireless']['mode'] = setting_wireless.get_mode() return status