mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
upgrades: Minor styling fixes
- Remove emacs mode line as emacs automatically detect Python files based on the #! line. - End comments with a '.'. - Use single quotes instead of double quotes for string for consistensy. - Update message to say that it take more than a minute to finish upgrades. Some times it takes a lot more than that.
This commit is contained in:
parent
a5473ae7f2
commit
d33e60c74a
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- mode: python -*-
|
|
||||||
#
|
#
|
||||||
# This file is part of Plinth.
|
# This file is part of Plinth.
|
||||||
#
|
#
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
<h2>{{ title }}</h2>
|
<h2>{{ title }}</h2>
|
||||||
|
|
||||||
<p>This will run unattended-upgrades, which will attempt to upgrade your system
|
<p>This will run unattended-upgrades, which will attempt to upgrade your system
|
||||||
with the latest Debian packages. It may take a minute to complete.</p>
|
with the latest Debian packages. It may take a few minutes to complete.</p>
|
||||||
|
|
||||||
<form class="form" method="post" action="{% url 'upgrades:run' %}">
|
<form class="form" method="post" action="{% url 'upgrades:run' %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
@ -39,16 +39,15 @@ subsubmenu = [{'url': reverse_lazy('upgrades:index'),
|
|||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""Initialize the module"""
|
"""Initialize the module."""
|
||||||
menu = cfg.main_menu.get('system:index')
|
menu = cfg.main_menu.get('system:index')
|
||||||
menu.add_urlname("Upgrades", "glyphicon-refresh",
|
menu.add_urlname(_('Upgrades'), 'glyphicon-refresh', 'upgrades:index', 21)
|
||||||
"upgrades:index", 21)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@package.required('unattended-upgrades')
|
@package.required('unattended-upgrades')
|
||||||
def index(request):
|
def index(request):
|
||||||
"""Serve the index page"""
|
"""Serve the index page."""
|
||||||
return TemplateResponse(request, 'upgrades.html',
|
return TemplateResponse(request, 'upgrades.html',
|
||||||
{'title': _('Package Upgrades'),
|
{'title': _('Package Upgrades'),
|
||||||
'subsubmenu': subsubmenu})
|
'subsubmenu': subsubmenu})
|
||||||
@ -58,7 +57,7 @@ def index(request):
|
|||||||
@require_POST
|
@require_POST
|
||||||
@package.required('unattended-upgrades')
|
@package.required('unattended-upgrades')
|
||||||
def run(request):
|
def run(request):
|
||||||
"""Run upgrades and show the output page"""
|
"""Run upgrades and show the output page."""
|
||||||
output = ''
|
output = ''
|
||||||
error = ''
|
error = ''
|
||||||
try:
|
try:
|
||||||
@ -76,7 +75,7 @@ def run(request):
|
|||||||
|
|
||||||
|
|
||||||
class ConfigureForm(forms.Form):
|
class ConfigureForm(forms.Form):
|
||||||
"""Configuration form"""
|
"""Configuration form to enable/disable automatic upgrades."""
|
||||||
auto_upgrades_enabled = forms.BooleanField(
|
auto_upgrades_enabled = forms.BooleanField(
|
||||||
label=_('Enable automatic upgrades'), required=False,
|
label=_('Enable automatic upgrades'), required=False,
|
||||||
help_text=_('When enabled, the unattended-upgrades program will be \
|
help_text=_('When enabled, the unattended-upgrades program will be \
|
||||||
@ -87,7 +86,7 @@ available.'))
|
|||||||
@login_required
|
@login_required
|
||||||
@package.required('unattended-upgrades')
|
@package.required('unattended-upgrades')
|
||||||
def configure(request):
|
def configure(request):
|
||||||
"""Serve the configuration form"""
|
"""Serve the configuration form."""
|
||||||
status = get_status()
|
status = get_status()
|
||||||
|
|
||||||
form = None
|
form = None
|
||||||
@ -108,13 +107,13 @@ def configure(request):
|
|||||||
|
|
||||||
|
|
||||||
def get_status():
|
def get_status():
|
||||||
"""Return the current status"""
|
"""Return the current status."""
|
||||||
output = actions.run('upgrades', ['check-auto'])
|
output = actions.run('upgrades', ['check-auto'])
|
||||||
return {'auto_upgrades_enabled': 'True' in output.split()}
|
return {'auto_upgrades_enabled': 'True' in output.split()}
|
||||||
|
|
||||||
|
|
||||||
def _apply_changes(request, old_status, new_status):
|
def _apply_changes(request, old_status, new_status):
|
||||||
"""Apply the form changes"""
|
"""Apply the form changes."""
|
||||||
if old_status['auto_upgrades_enabled'] \
|
if old_status['auto_upgrades_enabled'] \
|
||||||
== new_status['auto_upgrades_enabled']:
|
== new_status['auto_upgrades_enabled']:
|
||||||
messages.info(request, _('Setting unchanged'))
|
messages.info(request, _('Setting unchanged'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user