From ba6f461ece1b36f92b034d88215d948dc5530e78 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 6 Mar 2020 13:43:48 -0800 Subject: [PATCH] networks: Don't show router wizard if not behind a router If during the first wizard, the user selects that they are not behind a router, then don't show the router configuration wizard. Signed-off-by: Sunil Mohan Adapa --- plinth/modules/networks/views.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plinth/modules/networks/views.py b/plinth/modules/networks/views.py index 3d55fbd35..6c66e01c8 100644 --- a/plinth/modules/networks/views.py +++ b/plinth/modules/networks/views.py @@ -3,6 +3,7 @@ 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 @@ -478,6 +479,16 @@ 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 = kvstore.get_default( + networks.NETWORK_TOPOLOGY_TYPE_KEY, 'to_router') + 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())