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.
This commit is contained in:
Sunil Mohan Adapa 2015-10-11 16:13:01 +05:30
parent 408aa8910a
commit 682e5d7c2d
4 changed files with 6 additions and 5 deletions

View File

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

View File

@ -29,7 +29,7 @@
<div class="list-group-item clearfix">
{% if access_point.ssid %}
<a display="inline-block" width="40%"
href="{% url 'networks:add_wifi' access_point.ssid %}">
href="{% url 'networks:add_wifi' access_point.ssid access_point.interface_name %}">
{{ access_point.ssid }}
</a>
{% else %}

View File

@ -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<ssid>[^/]+)/)?$', 'add_wifi',
url(r'^sys/networks/add/wifi/(?:(?P<ssid>[^/]+)/(?P<interface_name>[^/]+)/)?$', 'add_wifi',
name='add_wifi'),
url(r'^sys/networks/(?P<uuid>[\w.@+-]+)/delete/$',
'delete', name='delete'),

View File

@ -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()})