From a95e59460edce05f733dcd31d085bce4f681e37e Mon Sep 17 00:00:00 2001 From: Nektarios Katakis Date: Sat, 15 Feb 2020 23:32:51 +0000 Subject: [PATCH] networks: Add first boot step for internet connection type Signed-off-by: Nektarios Katakis Reviewed-by: Sunil Mohan Adapa --- plinth/modules/networks/__init__.py | 17 ++++++++++++----- plinth/modules/networks/networks.py | 18 ++++++++++++++++-- plinth/modules/networks/urls.py | 5 ++++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/plinth/modules/networks/__init__.py b/plinth/modules/networks/__init__.py index 4ef678993..ed3dd35dd 100644 --- a/plinth/modules/networks/__init__.py +++ b/plinth/modules/networks/__init__.py @@ -18,11 +18,18 @@ is_essential = True managed_packages = ['network-manager', 'batctl'] -first_boot_steps = [{ - 'id': 'router_setup_wizard', - 'url': 'networks:firstboot_router_setup', - 'order': 4, -}] +first_boot_steps = [ + { + 'id': 'internet_connectivity_type', + 'url': 'networks:firstboot_internet_connection_type', + 'order': 3, + }, + { + 'id': 'router_setup_wizard', + 'url': 'networks:firstboot_router_setup', + 'order': 4, + }, +] _description = [ _('Configure network devices. Connect to the Internet via Ethernet, Wi-Fi ' diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index 4752a43cf..d227f4af3 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -457,12 +457,26 @@ def internet_connection_type_help_page(request): Show the internet connection type page. Used for first boot step and networks page. """ - # stub for now + is_firstboot = True \ + if 'firstboot' in request.build_absolute_uri() else False + if request.method == 'POST': - resp = reverse_lazy('networks:index') + if is_firstboot: + resp = reverse_lazy(first_boot.next_step()) + else: + resp = reverse_lazy('networks:index') + messages.success(request, _('Internet connection type saved.')) else: html = "internet_connectivity_type.html" template_kwargs = {'form': InternetConnectionTypeForm} + if is_firstboot: + html = "internet_connectivity_type_firstboot.html" + + # mark step done on firstboot visit to get the next_step + first_boot.mark_step_done('router_setup_wizard') + template_kwargs.update({ + 'first_boot_next_step': reverse_lazy(first_boot.next_step()), + }) resp = TemplateResponse(request, html, template_kwargs) diff --git a/plinth/modules/networks/urls.py b/plinth/modules/networks/urls.py index abf054380..872c3a02d 100644 --- a/plinth/modules/networks/urls.py +++ b/plinth/modules/networks/urls.py @@ -30,10 +30,13 @@ urlpatterns = [ url(r'^sys/networks/router-setup-guide/$', views.router_configuration_help_page, name='router_setup'), - url(r'^sys/networks/firstboot/$', + url(r'^sys/networks/firstboot/router_setup/$', public(views.router_configuration_help_page), name='firstboot_router_setup'), url(r'^sys/networks/internet-connection-type/$', views.internet_connection_type_help_page, name='internet_connection_type_setup'), + url(r'^sys/networks/firstboot/internet_connection_type/$', + public(views.internet_connection_type_help_page), + name='firstboot_internet_connection_type'), ]