mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
networks: Save to kvstore internet connectivity type
Signed-off-by: Nektarios Katakis <iam@nektarioskatakis.xyz> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
a95e59460e
commit
a8cd9c0b4a
@ -43,6 +43,7 @@ logger = Logger(__name__)
|
|||||||
app = None
|
app = None
|
||||||
|
|
||||||
ROUTER_CONFIGURATION_TYPE_KEY = 'networks_router_configuration_type'
|
ROUTER_CONFIGURATION_TYPE_KEY = 'networks_router_configuration_type'
|
||||||
|
INTERNET_CONNECTION_TYPE_KEY = 'networks_internet_type'
|
||||||
|
|
||||||
|
|
||||||
class NetworksApp(app_module.App):
|
class NetworksApp(app_module.App):
|
||||||
|
|||||||
@ -460,24 +460,34 @@ def internet_connection_type_help_page(request):
|
|||||||
is_firstboot = True \
|
is_firstboot = True \
|
||||||
if 'firstboot' in request.build_absolute_uri() else False
|
if 'firstboot' in request.build_absolute_uri() else False
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST' and request.POST['internet_connection_type']:
|
||||||
|
form = InternetConnectionTypeForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
logger.info('Updating internet connectivity type with value: %s' %
|
||||||
|
request.POST['internet_connection_type'])
|
||||||
|
kvstore.set(
|
||||||
|
networks.INTERNET_CONNECTION_TYPE_KEY,
|
||||||
|
request.POST['internet_connection_type'],
|
||||||
|
)
|
||||||
if is_firstboot:
|
if is_firstboot:
|
||||||
resp = reverse_lazy(first_boot.next_step())
|
return redirect(reverse_lazy(first_boot.next_step()))
|
||||||
else:
|
else:
|
||||||
resp = reverse_lazy('networks:index')
|
|
||||||
messages.success(request, _('Internet connection type saved.'))
|
messages.success(request, _('Internet connection type saved.'))
|
||||||
|
return redirect(reverse_lazy('networks:index'))
|
||||||
else:
|
else:
|
||||||
html = "internet_connectivity_type.html"
|
html = "internet_connectivity_type.html"
|
||||||
template_kwargs = {'form': InternetConnectionTypeForm}
|
initial = {
|
||||||
|
"internet_connection_type": kvstore.get_default(
|
||||||
|
networks.INTERNET_CONNECTION_TYPE_KEY, 'dynamic_public_ip'),
|
||||||
|
}
|
||||||
|
template_kwargs = {'form': InternetConnectionTypeForm(initial=initial)}
|
||||||
if is_firstboot:
|
if is_firstboot:
|
||||||
html = "internet_connectivity_type_firstboot.html"
|
html = "internet_connectivity_firstboot.html"
|
||||||
|
|
||||||
# mark step done on firstboot visit to get the next_step
|
# mark step done on firstboot visit to get the next_step
|
||||||
first_boot.mark_step_done('router_setup_wizard')
|
first_boot.mark_step_done('internet_connectivity_type')
|
||||||
template_kwargs.update({
|
template_kwargs.update({
|
||||||
'first_boot_next_step': reverse_lazy(first_boot.next_step()),
|
'first_boot_next_step': reverse_lazy(first_boot.next_step()),
|
||||||
})
|
})
|
||||||
|
|
||||||
resp = TemplateResponse(request, html, template_kwargs)
|
return TemplateResponse(request, html, template_kwargs)
|
||||||
|
|
||||||
return resp
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user