Sunil Mohan Adapa 35312bd672
first_boot: Allow the next steps page to be revisited
- Currently, after the user arrives the 'next steps' page after completing the
first setup, trying to refresh the page takes us away from the page to the index
page.

- Since this page lists a lot of steps, user can't be expected to memorize the
contents of the page and perform them one after the another. Opening the links
in popups instead of navigating away from page helps but not full solve the
problem.

- If the page is a regular page and not part of the first step wizard, this page
is a simple Django page. It can be refreshed. Back button can be used to view
the page after navigating from it again.

Tests:

- On stable and testing containers, remove the sqlite3 file and start the
service. This will trigger the first setup wizard. As a last step of the wizard,
the 'setup complete! Next steps:' page is shown.

- Refreshing the page works.

- Navigating away from the page and using the back button to return to it works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-10 09:23:36 +03:00

43 lines
1.4 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
from django import http
from django.urls import reverse
from django.utils.translation import gettext as _
from django.views.generic import TemplateView
from django.views.generic.edit import FormView
from plinth.modules import first_boot
from .forms import FirstbootWizardSecretForm
class WelcomeView(FormView):
"""Show the welcome screen."""
form_class = FirstbootWizardSecretForm
template_name = 'firstboot_welcome.html'
def form_valid(self, form):
"""If form is valid, mark this step as done and move to next step."""
self.request.session['firstboot_secret_provided'] = True
first_boot.mark_step_done('firstboot_welcome')
return http.HttpResponseRedirect(reverse(first_boot.next_step()))
def get_context_data(self, **kwargs):
"""Add network connections to context list."""
context = super().get_context_data(**kwargs)
show_prompt = first_boot.firstboot_wizard_secret_exists()
context['show_wizard_password_prompt'] = show_prompt
return context
class CompleteView(TemplateView):
"""Show next steps after all firstboot wizard steps are done."""
template_name = 'firstboot_complete.html'
def get_context_data(self, **kwargs):
"""Add network connections to context list."""
context = super().get_context_data(**kwargs)
context['title'] = _('Setup Complete')
return context