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 <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2020-03-06 13:43:48 -08:00
parent 8a93b5191f
commit ba6f461ece
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -3,6 +3,7 @@
import logging import logging
from django.contrib import messages from django.contrib import messages
from django.http import HttpResponseRedirect
from django.shortcuts import redirect from django.shortcuts import redirect
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.urls import reverse_lazy from django.urls import reverse_lazy
@ -478,6 +479,16 @@ class RouterConfigurationFirstBootView(RouterConfigurationView):
"""View for router configuration form during first wizard.""" """View for router configuration form during first wizard."""
template_name = 'router_configuration_firstboot.html' 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): def get_success_url(self):
"""Return the next wizard step after this one.""" """Return the next wizard step after this one."""
return reverse_lazy(first_boot.next_step()) return reverse_lazy(first_boot.next_step())