From 682e5d7c2d91fc48cd833950804355bda4c46f29 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 11 Oct 2015 16:13:01 +0530 Subject: [PATCH] networks: Prefill proper Wi-Fi device in add form Add access points found on a particular Wi-Fi device only to that device as it is not gauranteed that other Wi-Fi devices will be able to find them. For example, an access point operating in 5 GHz frequency will only be found and used by Wi-Fi devices capable for 5 GHz communication. --- plinth/modules/networks/networks.py | 6 +++--- plinth/modules/networks/templates/wifi_scan.html | 2 +- plinth/modules/networks/urls.py | 2 +- plinth/network.py | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index 8bff13806..c4a368242 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -354,15 +354,15 @@ def add_pppoe(request): 'form': form}) -def add_wifi(request, ssid=None): +def add_wifi(request, ssid=None, interface_name=None): """Serve wifi connection create form.""" form = None form_data = None if ssid: - device = network.get_first_wifi_device() + device = network.get_device_by_interface_name(interface_name) form_data = {'name': ssid, - 'interface': device, + 'interface': interface_name if device else None, 'zone': 'external', 'ssid': ssid, 'mode': 'infrastructure', diff --git a/plinth/modules/networks/templates/wifi_scan.html b/plinth/modules/networks/templates/wifi_scan.html index 54a7a38e8..092c287aa 100644 --- a/plinth/modules/networks/templates/wifi_scan.html +++ b/plinth/modules/networks/templates/wifi_scan.html @@ -29,7 +29,7 @@
{% if access_point.ssid %} + href="{% url 'networks:add_wifi' access_point.ssid access_point.interface_name %}"> {{ access_point.ssid }} {% else %} diff --git a/plinth/modules/networks/urls.py b/plinth/modules/networks/urls.py index ad483a737..d07739551 100644 --- a/plinth/modules/networks/urls.py +++ b/plinth/modules/networks/urls.py @@ -37,7 +37,7 @@ urlpatterns = patterns( url(r'^sys/networks/add/$', 'add', name='add'), url(r'^sys/networks/add/ethernet/$', 'add_ethernet', name='add_ethernet'), url(r'^sys/networks/add/pppoe/$', 'add_pppoe', name='add_pppoe'), - url(r'^sys/networks/add/wifi/(?:(?P[^/]+)/)?$', 'add_wifi', + url(r'^sys/networks/add/wifi/(?:(?P[^/]+)/(?P[^/]+)/)?$', 'add_wifi', name='add_wifi'), url(r'^sys/networks/(?P[\w.@+-]+)/delete/$', 'delete', name='delete'), diff --git a/plinth/network.py b/plinth/network.py index 2a5287900..fb2794ef8 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -624,6 +624,7 @@ def wifi_scan(): ssid = access_point.get_ssid() ssid_string = ssid.get_data() if ssid else '' access_points.append({ + 'interface_name': device.get_iface(), 'ssid': ssid_string, 'strength': access_point.get_strength()})