From ed3363105a2991a0545b21643ed121f830778798 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 7 Oct 2024 06:58:49 -0700 Subject: [PATCH] networks: Remove first boot steps for connectivity/topology - We have not yet implemented the main reason they exist. To guide users to establish reachability with Tor hidden services, Pagekite, Dynamic DNS, etc. - We now have a 'Next steps' page that talks about configuring network connections. The networks page linked from here has these steps prominently listed. - In the future we will implement a wizard for reachability and these steps will still be used. However, they don't have to part of first setup. They can add them as notification and as part of next steps page. - It is good to have a simplified first setup wizard. It is seldom tested properly. Tests: - Run the first setup wizard by removing /var/lib/plinth/plinth.sqlite3 and running the service. Notice that the software update step is not shown and wizard completes successfully. [vexch: Minor quote fix in functional tests] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/modules/networks/__init__.py | 18 ------ .../internet_connectivity_firstboot.html | 23 ------- .../templates/network_topology_firstboot.html | 24 ------- .../router_configuration_firstboot.html | 24 ------- plinth/modules/networks/urls.py | 9 --- plinth/modules/networks/views.py | 64 +------------------ plinth/tests/functional/__init__.py | 8 +-- 7 files changed, 2 insertions(+), 168 deletions(-) delete mode 100644 plinth/modules/networks/templates/internet_connectivity_firstboot.html delete mode 100644 plinth/modules/networks/templates/network_topology_firstboot.html delete mode 100644 plinth/modules/networks/templates/router_configuration_firstboot.html diff --git a/plinth/modules/networks/__init__.py b/plinth/modules/networks/__init__.py index f71dc5f72..3291e79a9 100644 --- a/plinth/modules/networks/__init__.py +++ b/plinth/modules/networks/__init__.py @@ -15,24 +15,6 @@ from plinth.package import Packages from . import privileged -first_boot_steps = [ - { - 'id': 'network_topology_wizard', - 'url': 'networks:network-topology-first-boot', - 'order': 2, - }, - { - 'id': 'router_setup_wizard', - 'url': 'networks:router-configuration-first-boot', - 'order': 3, - }, - { - 'id': 'internet_connectivity_type_wizard', - 'url': 'networks:internet-connection-type-first-boot', - 'order': 4, - }, -] - _description = [ _('Configure network devices. Connect to the Internet via Ethernet, Wi-Fi ' 'or PPPoE. Share that connection with other devices on the network.'), diff --git a/plinth/modules/networks/templates/internet_connectivity_firstboot.html b/plinth/modules/networks/templates/internet_connectivity_firstboot.html deleted file mode 100644 index 6bd240144..000000000 --- a/plinth/modules/networks/templates/internet_connectivity_firstboot.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "base_firstboot.html" %} -{% comment %} -# SPDX-License-Identifier: AGPL-3.0-or-later -{% endcomment %} - -{% load bootstrap %} -{% load i18n %} -{% load static %} - -{% block content %} - {% include "internet_connectivity_content.html" %} - -
- {% csrf_token %} - - {{ form|bootstrap }} - - - -
-{% endblock %} diff --git a/plinth/modules/networks/templates/network_topology_firstboot.html b/plinth/modules/networks/templates/network_topology_firstboot.html deleted file mode 100644 index 4c3eafbb0..000000000 --- a/plinth/modules/networks/templates/network_topology_firstboot.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "base_firstboot.html" %} -{% comment %} -# SPDX-License-Identifier: AGPL-3.0-or-later -{% endcomment %} - -{% load bootstrap %} -{% load i18n %} -{% load static %} - -{% block content %} - {% include "network_topology_content.html" %} - -
- {% csrf_token %} - - {{ form|bootstrap }} - - - -
- -{% endblock %} diff --git a/plinth/modules/networks/templates/router_configuration_firstboot.html b/plinth/modules/networks/templates/router_configuration_firstboot.html deleted file mode 100644 index 74877e993..000000000 --- a/plinth/modules/networks/templates/router_configuration_firstboot.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "base_firstboot.html" %} -{% comment %} -# SPDX-License-Identifier: AGPL-3.0-or-later -{% endcomment %} - -{% load bootstrap %} -{% load i18n %} -{% load static %} - -{% block content %} - {% include "router_configuration_content.html" %} - -
- {% csrf_token %} - - {{ form|bootstrap }} - - - -
- -{% endblock %} diff --git a/plinth/modules/networks/urls.py b/plinth/modules/networks/urls.py index b32f8f715..f9fc8f72b 100644 --- a/plinth/modules/networks/urls.py +++ b/plinth/modules/networks/urls.py @@ -32,18 +32,9 @@ urlpatterns = [ re_path(r'^sys/networks/router-configuration/$', views.RouterConfigurationView.as_view(), name='router-configuration'), - re_path(r'^sys/networks/firstboot/router-configuration/$', - views.RouterConfigurationFirstBootView.as_view(), - name='router-configuration-first-boot'), re_path(r'^sys/networks/internet-connection-type/$', views.InternetConnectionTypeView.as_view(), name='internet-connection-type'), - re_path(r'^sys/networks/firstboot/internet-connection-type/$', - views.InternetConnectionTypeFirstBootView.as_view(), - name='internet-connection-type-first-boot'), re_path(r'^sys/networks/network-topology/$', views.NetworkTopologyView.as_view(), name='network-topology'), - re_path(r'^sys/networks/firstboot/network-topology-first-boot/$', - views.NetworkTopologyFirstBootView.as_view(), - name='network-topology-first-boot'), ] diff --git a/plinth/modules/networks/views.py b/plinth/modules/networks/views.py index 6acc66ae8..5074b796f 100644 --- a/plinth/modules/networks/views.py +++ b/plinth/modules/networks/views.py @@ -3,7 +3,6 @@ import logging from django.contrib import messages -from django.http import HttpResponseRedirect from django.shortcuts import redirect from django.template.response import TemplateResponse from django.urls import reverse_lazy @@ -13,7 +12,7 @@ from django.views.decorators.http import require_POST from django.views.generic.edit import FormView from plinth import network -from plinth.modules import first_boot, names, networks +from plinth.modules import names, networks from plinth.views import AppView from .forms import (ConnectionTypeSelectForm, EthernetForm, GenericForm, @@ -561,24 +560,6 @@ class NetworkTopologyView(FormView): return super().form_valid(form) -class NetworkTopologyFirstBootView(NetworkTopologyView): - """View for network topology form during first wizard.""" - template_name = 'network_topology_firstboot.html' - - def get_success_url(self): - """Return next fistboot step.""" - return reverse_lazy(first_boot.next_step()) - - def form_valid(self, form): - """Mark the first wizard step as done, save value and redirect.""" - first_boot.mark_step_done('network_topology_wizard') - if 'skip' in form.data: - first_boot.mark_step_done('router_setup_wizard') - return FormView.form_valid(self, form) - - return super().form_valid(form) - - class RouterConfigurationView(FormView): """View for router configuration form.""" template_name = 'router_configuration_update.html' @@ -597,32 +578,6 @@ class RouterConfigurationView(FormView): return super().form_valid(form) -class RouterConfigurationFirstBootView(RouterConfigurationView): - """View for router configuration form during first wizard.""" - template_name = 'router_configuration_firstboot.html' - - def dispatch(self, request, *args, **kwargs): - """Don't show wizard step if FreedomBox is not behind a router.""" - network_topology = networks.get_network_topology_type() - if network_topology != 'to_router': - first_boot.mark_step_done('router_setup_wizard') - return HttpResponseRedirect(reverse_lazy(first_boot.next_step())) - - return super().dispatch(request, *args, *kwargs) - - def get_success_url(self): - """Return the next wizard step after this one.""" - return reverse_lazy(first_boot.next_step()) - - def form_valid(self, form): - """Mark the first wizard step as done, save value and redirect.""" - first_boot.mark_step_done('router_setup_wizard') - if 'skip' in form.data: - return FormView.form_valid(self, form) - - return super().form_valid(form) - - class InternetConnectionTypeView(FormView): """View for Internet connection type form.""" template_name = 'internet_connectivity_type.html' @@ -642,20 +597,3 @@ class InternetConnectionTypeView(FormView): logger.info('Updating internet connectivity type: %s', type_) networks.set_internet_connection_type(type_) return super().form_valid(form) - - -class InternetConnectionTypeFirstBootView(InternetConnectionTypeView): - """View to show Internet connection type form during first wizard.""" - template_name = 'internet_connectivity_firstboot.html' - - def get_success_url(self): - """Return the next wizard step after this one.""" - return reverse_lazy(first_boot.next_step()) - - def form_valid(self, form): - """Mark the first wizard step as done, save value and redirect.""" - first_boot.mark_step_done('internet_connectivity_type_wizard') - if 'skip' in form.data: - return FormView.form_valid(self, form) - - return super().form_valid(form) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 57ed0a91e..2d652646d 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -345,12 +345,6 @@ def login_with_account(browser, url, username, password=None): browser.visit(base_url + '/plinth/firstboot/welcome') submit(browser, form_class='form-start') # "Start Setup" button _create_admin_account(browser, username, password) - if '/network-topology-first-boot' in browser.url: - submit(browser, element=browser.find_by_name('skip')[0]) - - if '/internet-connection-type' in browser.url: - submit(browser, element=browser.find_by_name('skip')[0]) - if '/firstboot/backports' in browser.url: submit(browser, element=browser.find_by_name('next')[0]) @@ -614,7 +608,7 @@ def networks_set_firewall_zone(browser, zone): 'and contains(@class, "connection-status-label")]/following::a').first network_id = device['href'].split('/')[-3] device.click() - edit_url = "/plinth/sys/networks/{}/edit/".format(network_id) + edit_url = '/plinth/sys/networks/{}/edit/'.format(network_id) browser.links.find_by_href(edit_url).first.click() browser.select('zone', zone) submit(browser, form_class='form-connection-edit')