mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Connect to network selected from scan page.
This commit is contained in:
parent
c0cd01221e
commit
f63d8d29de
@ -123,7 +123,7 @@ def activate(request, conn_id):
|
||||
return redirect(reverse_lazy('networks:index'))
|
||||
|
||||
messages.success(request, _('Activated connection %s.') % name)
|
||||
return redirect(reverse_lazy('network:index'))
|
||||
return redirect(reverse_lazy('networks:index'))
|
||||
|
||||
|
||||
@login_required
|
||||
@ -148,6 +148,32 @@ def scan(request):
|
||||
'aps': aps})
|
||||
|
||||
|
||||
@login_required
|
||||
def connect(request, connect_path):
|
||||
"""Create a new wifi connection to an existing AP."""
|
||||
form = None
|
||||
ssid = urllib.parse.unquote_plus(connect_path)
|
||||
form_data = {'name': ssid, 'ssid': ssid, 'ipv4_method': 'auto'}
|
||||
|
||||
if request.method == 'POST':
|
||||
form = AddWifiForm(request.POST)
|
||||
if form.is_valid():
|
||||
name = form.cleaned_data['name']
|
||||
ssid = form.cleaned_data['ssid']
|
||||
ipv4_method = form.cleaned_data['ipv4_method']
|
||||
ipv4_address = form.cleaned_data['ipv4_address']
|
||||
|
||||
network.add_wifi_connection(name, ssid, ipv4_method, ipv4_address)
|
||||
return redirect(reverse_lazy('networks:index'))
|
||||
else:
|
||||
form = AddWifiForm(form_data)
|
||||
|
||||
return TemplateResponse(request, 'connections_create.html',
|
||||
{'title': _('Connect to Wi-Fi Network'),
|
||||
'subsubmenu': subsubmenu,
|
||||
'form': form})
|
||||
|
||||
|
||||
@login_required
|
||||
def add(request):
|
||||
"""Serve the connection type selection form."""
|
||||
|
||||
@ -27,7 +27,10 @@
|
||||
<div class="list-group">
|
||||
{% for ap in aps %}
|
||||
<div class="list-group-item clearfix">
|
||||
<a display="inline-block" width="40%">{{ ap.ssid }}</a>
|
||||
<a display="inline-block" width="40%"
|
||||
href="{% url 'networks:connect' ap.connect_path %}">
|
||||
{{ ap.ssid }}
|
||||
</a>
|
||||
<span class="btn btn-primary btn-xs pull-right">
|
||||
{{ ap.strength }}%
|
||||
</span>
|
||||
|
||||
@ -32,6 +32,7 @@ urlpatterns = patterns(
|
||||
url(r'^sys/networks/(?P<conn_id>[\w.@+-]+)/deactivate/$',
|
||||
'deactivate', name='deactivate'),
|
||||
url(r'^sys/networks/scan/$', 'scan', name='scan'),
|
||||
url(r'^sys/networks/connect/(?P<connect_path>[\w.@+-]+)/$', 'connect', name='connect'),
|
||||
url(r'^sys/networks/add/$', 'add', name='add'),
|
||||
url(r'^sys/networks/add/ethernet/$', 'add_ethernet', name='add_ethernet'),
|
||||
url(r'^sys/networks/add/wifi/$', 'add_wifi', name='add_wifi'),
|
||||
|
||||
@ -244,5 +244,6 @@ def wifi_scan():
|
||||
continue
|
||||
for ap in dev.SpecificDevice().GetAccessPoints():
|
||||
aps.append({'ssid': ap.Ssid,
|
||||
'connect_path': urllib.parse.quote_plus(ap.Ssid),
|
||||
'strength': ord(ap.Strength)})
|
||||
return aps
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user