mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
upgrades: Add first boot step to run initial update
Closes: #1708. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
377010b078
commit
8b02c2bf3a
@ -30,6 +30,11 @@ first_boot_steps = [
|
|||||||
'url': 'upgrades:backports-firstboot',
|
'url': 'upgrades:backports-firstboot',
|
||||||
'order': 5,
|
'order': 5,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'id': 'initial_update',
|
||||||
|
'url': 'upgrades:update-firstboot',
|
||||||
|
'order': 6,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
_description = [
|
_description = [
|
||||||
|
|||||||
@ -33,3 +33,9 @@ class BackportsFirstbootForm(forms.Form):
|
|||||||
backports_enabled = forms.BooleanField(
|
backports_enabled = forms.BooleanField(
|
||||||
label=_('Activate frequent feature updates (recommended)'),
|
label=_('Activate frequent feature updates (recommended)'),
|
||||||
required=False, initial=True)
|
required=False, initial=True)
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateFirstbootForm(forms.Form):
|
||||||
|
"""Form to run or skip initial update during first boot wizard."""
|
||||||
|
update_now = forms.BooleanField(label=_('Update now (recommended)'),
|
||||||
|
required=False, initial=True)
|
||||||
|
|||||||
37
plinth/modules/upgrades/templates/update-firstboot.html
Normal file
37
plinth/modules/upgrades/templates/update-firstboot.html
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{% extends "base_firstboot.html" %}
|
||||||
|
{% comment %}
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load bootstrap %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>{% trans "Update" %}</h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% blocktrans trimmed %}
|
||||||
|
Check for and apply the latest software and security updates.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% blocktrans trimmed %}
|
||||||
|
<strong>This may take a long time to complete.</strong> During an update,
|
||||||
|
you cannot install apps. Also, this web interface may be temporarily
|
||||||
|
unavailable and show an error. In that case, refresh the page to
|
||||||
|
continue.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form class="form" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{{ form|bootstrap }}
|
||||||
|
|
||||||
|
<input type="submit" class="btn btn-primary" name="update"
|
||||||
|
value="{% trans "Next" %}"/>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@ -14,5 +14,7 @@ urlpatterns = [
|
|||||||
name='activate-backports'),
|
name='activate-backports'),
|
||||||
url(r'^sys/upgrades/firstboot/backports/$',
|
url(r'^sys/upgrades/firstboot/backports/$',
|
||||||
views.BackportsFirstbootView.as_view(), name='backports-firstboot'),
|
views.BackportsFirstbootView.as_view(), name='backports-firstboot'),
|
||||||
|
url(r'^sys/upgrades/firstboot/update/$',
|
||||||
|
views.UpdateFirstbootView.as_view(), name='update-firstboot'),
|
||||||
url(r'^sys/upgrades/upgrade/$', views.upgrade, name='upgrade'),
|
url(r'^sys/upgrades/upgrade/$', views.upgrade, name='upgrade'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -17,7 +17,7 @@ from plinth.errors import ActionError
|
|||||||
from plinth.modules import first_boot, upgrades
|
from plinth.modules import first_boot, upgrades
|
||||||
from plinth.views import AppView
|
from plinth.views import AppView
|
||||||
|
|
||||||
from .forms import BackportsFirstbootForm, ConfigureForm
|
from .forms import BackportsFirstbootForm, ConfigureForm, UpdateFirstbootForm
|
||||||
|
|
||||||
|
|
||||||
class UpgradesConfigurationView(AppView):
|
class UpgradesConfigurationView(AppView):
|
||||||
@ -172,3 +172,21 @@ class BackportsFirstbootView(FormView):
|
|||||||
upgrades.setup_repositories(None)
|
upgrades.setup_repositories(None)
|
||||||
first_boot.mark_step_done('backports_wizard')
|
first_boot.mark_step_done('backports_wizard')
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateFirstbootView(FormView):
|
||||||
|
"""View to run initial update during first boot wizard."""
|
||||||
|
template_name = 'update-firstboot.html'
|
||||||
|
form_class = UpdateFirstbootForm
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
"""Return next firstboot step."""
|
||||||
|
return reverse_lazy(first_boot.next_step())
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
"""Run update if selected, and mark step as done."""
|
||||||
|
if form.cleaned_data['update_now']:
|
||||||
|
actions.superuser_run('upgrades', ['run'])
|
||||||
|
|
||||||
|
first_boot.mark_step_done('initial_update')
|
||||||
|
return super().form_valid(form)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user