power: Minor updates

- Change term 'reboot' to 'restart' as it is less techinical and more
  consistent with popular interaces on desktop/mobiles.

- Updated description for power module.

- Simplify the module title to just 'Power'.

- Update the use of elipses and angular quotes as angular quotes and
  elipses are both used to indicate that further user interface will be
  available after pressing the button.

- Remove suprious '\' in power_reboot.html.

- Notify to the user that web interface will not be available after
  reboot/shutdown.

- Redirect the user to application page after restart/shutdown.  If the
  page serve succeeds, they will have simply refresh/access it after
  restart/shutdown after waiting or powering on.
This commit is contained in:
Sunil Mohan Adapa 2015-11-27 11:40:09 +05:30
parent a002ca300c
commit a0da928dae
6 changed files with 29 additions and 28 deletions

View File

@ -29,14 +29,14 @@ def parse_arguments():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
subparsers.add_parser('reboot', help='Reboot the system')
subparsers.add_parser('restart', help='Restart the system')
subparsers.add_parser('shutdown', help='Shut down the system')
return parser.parse_args()
def subcommand_reboot(_):
"""Reboot the system."""
def subcommand_restart(_):
"""Restart the system."""
subprocess.call('reboot')

View File

@ -26,19 +26,15 @@
<h2>{{ title }}</h2>
<p>
{% blocktrans trimmed %}
From here, it is possible to reboot or shut down the system.
{% endblocktrans %}
{% blocktrans trimmed %}Restart or shut down the system.{% endblocktrans %}
</p>
<p>
<a class="btn btn-primary btn-md" href="{% url 'power:reboot' %}">
{% trans "Reboot..." %}</a>
</p>
<a class="btn btn-default btn-md" href="{% url 'power:restart' %}">
{% trans "Restart &raquo;" %}</a>
<p>
<a class="btn btn-primary btn-md" href="{% url 'power:shutdown' %}">
{% trans "Shut Down..." %}</a>
<a class="btn btn-default btn-md" href="{% url 'power:shutdown' %}">
{% trans "Shut Down &raquo;" %}</a>
</p>
{% endblock %}

View File

@ -1,4 +1,4 @@
\{% extends "base.html" %}
{% extends "base.html" %}
{% comment %}
#
# This file is part of Plinth.
@ -27,7 +27,9 @@
<p>
{% blocktrans trimmed %}
Are you sure you want to reboot?
Are you sure you want to restart? You will not be able to access
this web interface for a few minutes until the system is
restarted.
{% endblocktrans %}
</p>
@ -37,8 +39,7 @@
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary"
value="{% trans "Reboot Now &raquo;" %}"/>
value="{% trans "Restart Now" %}"/>
</form>
{% endblock %}

View File

@ -27,7 +27,8 @@
<p>
{% blocktrans trimmed %}
Are you sure you want to shut down?
Are you sure you want to shut down? You will not be able to
access this web interface after shut down.
{% endblocktrans %}
</p>
@ -37,7 +38,7 @@
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary"
value="{% trans "Shut Down Now &raquo;" %}"/>
value="{% trans "Shut Down Now" %}"/>
</form>

View File

@ -24,6 +24,6 @@ from django.conf.urls import patterns, url
urlpatterns = patterns(
'plinth.modules.power.views',
url(r'^sys/power/$', 'index', name='index'),
url(r'^sys/power/reboot$', 'reboot', name='reboot'),
url(r'^sys/power/restart$', 'restart', name='restart'),
url(r'^sys/power/shutdown$', 'shutdown', name='shutdown'),
)

View File

@ -20,6 +20,8 @@ Plinth module for power module.
"""
from django.forms import Form
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.utils.translation import ugettext as _
@ -28,21 +30,21 @@ from plinth import actions
def index(request):
"""Serve power controls page."""
return TemplateResponse(request, 'power.html',
{'title': _('Power Control')})
return TemplateResponse(request, 'power.html', {'title': _('Power')})
def reboot(request):
"""Serve reboot confirmation page."""
def restart(request):
"""Serve start confirmation page."""
form = None
if request.method == 'POST':
actions.superuser_run('power', ['reboot'])
actions.superuser_run('power', ['restart'], async=True)
return redirect(reverse('apps:index'))
else:
form = Form(prefix='power')
return TemplateResponse(request, 'power_reboot.html',
{'title': _('Power Control'),
return TemplateResponse(request, 'power_restart.html',
{'title': _('Power'),
'form': form})
@ -51,10 +53,11 @@ def shutdown(request):
form = None
if request.method == 'POST':
actions.superuser_run('power', ['shutdown'])
actions.superuser_run('power', ['shutdown'], async=True)
return redirect(reverse('apps:index'))
else:
form = Form(prefix='power')
return TemplateResponse(request, 'power_shutdown.html',
{'title': _('Power Control'),
{'title': _('Power'),
'form': form})