help: Add Debian release to about page.

This commit is contained in:
Johannes Keyser 2017-05-26 00:24:44 +02:00 committed by James Valleroy
parent cc5e49433a
commit 5ee8e9397d
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 20 additions and 3 deletions

View File

@ -57,7 +57,8 @@ def about(request):
context = {
'title': _('About {box_name}').format(box_name=_(cfg.box_name)),
'version': __version__,
'new_version': not plinth.candidate.is_installed
'new_version': not plinth.candidate.is_installed,
'os_release': get_os_release()
}
return TemplateResponse(request, 'help_about.html', context)
@ -90,3 +91,15 @@ def status_log(request):
'data': data
}
return TemplateResponse(request, 'statuslog.html', context)
def get_os_release():
"""Returns the Debian release number and name"""
output = 'Error: Cannot read PRETTY_NAME in /etc/os-release.'
with open('/etc/os-release', 'r') as release_file:
for line in release_file:
if 'PRETTY_NAME=' in line:
line = line.replace('"', '').strip()
line = line.split('=')
output = line[1]
return output

View File

@ -74,12 +74,16 @@
<p style='margin-top:30px'>
{% blocktrans trimmed %}
You are running Plinth version {{ version }}.
You are running {{ os_release }} and Plinth version {{ version }}.
{% endblocktrans %}
{% if new_version %}
{% blocktrans trimmed %}
There is a new version available.
There is a new Plinth version available.
{% endblocktrans %}
{% else %}
{% blocktrans trimmed %}
Plinth is up to date.
{% endblocktrans %}
{% endif %}
</p>