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() parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') 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') subparsers.add_parser('shutdown', help='Shut down the system')
return parser.parse_args() return parser.parse_args()
def subcommand_reboot(_): def subcommand_restart(_):
"""Reboot the system.""" """Restart the system."""
subprocess.call('reboot') subprocess.call('reboot')

View File

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

View File

@ -1,4 +1,4 @@
\{% extends "base.html" %} {% extends "base.html" %}
{% comment %} {% comment %}
# #
# This file is part of Plinth. # This file is part of Plinth.
@ -27,7 +27,9 @@
<p> <p>
{% blocktrans trimmed %} {% 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 %} {% endblocktrans %}
</p> </p>
@ -37,8 +39,7 @@
{{ form|bootstrap }} {{ form|bootstrap }}
<input type="submit" class="btn btn-primary" <input type="submit" class="btn btn-primary"
value="{% trans "Reboot Now &raquo;" %}"/> value="{% trans "Restart Now" %}"/>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -27,7 +27,8 @@
<p> <p>
{% blocktrans trimmed %} {% 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 %} {% endblocktrans %}
</p> </p>
@ -37,7 +38,7 @@
{{ form|bootstrap }} {{ form|bootstrap }}
<input type="submit" class="btn btn-primary" <input type="submit" class="btn btn-primary"
value="{% trans "Shut Down Now &raquo;" %}"/> value="{% trans "Shut Down Now" %}"/>
</form> </form>

View File

@ -24,6 +24,6 @@ from django.conf.urls import patterns, url
urlpatterns = patterns( urlpatterns = patterns(
'plinth.modules.power.views', 'plinth.modules.power.views',
url(r'^sys/power/$', 'index', name='index'), 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'), 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.forms import Form
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
@ -28,21 +30,21 @@ from plinth import actions
def index(request): def index(request):
"""Serve power controls page.""" """Serve power controls page."""
return TemplateResponse(request, 'power.html', return TemplateResponse(request, 'power.html', {'title': _('Power')})
{'title': _('Power Control')})
def reboot(request): def restart(request):
"""Serve reboot confirmation page.""" """Serve start confirmation page."""
form = None form = None
if request.method == 'POST': if request.method == 'POST':
actions.superuser_run('power', ['reboot']) actions.superuser_run('power', ['restart'], async=True)
return redirect(reverse('apps:index'))
else: else:
form = Form(prefix='power') form = Form(prefix='power')
return TemplateResponse(request, 'power_reboot.html', return TemplateResponse(request, 'power_restart.html',
{'title': _('Power Control'), {'title': _('Power'),
'form': form}) 'form': form})
@ -51,10 +53,11 @@ def shutdown(request):
form = None form = None
if request.method == 'POST': if request.method == 'POST':
actions.superuser_run('power', ['shutdown']) actions.superuser_run('power', ['shutdown'], async=True)
return redirect(reverse('apps:index'))
else: else:
form = Form(prefix='power') form = Form(prefix='power')
return TemplateResponse(request, 'power_shutdown.html', return TemplateResponse(request, 'power_shutdown.html',
{'title': _('Power Control'), {'title': _('Power'),
'form': form}) 'form': form})