Sunil Mohan Adapa a0da928dae 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.
2015-11-27 11:40:09 +05:30

64 lines
1.9 KiB
Python

#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
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 _
from plinth import actions
def index(request):
"""Serve power controls page."""
return TemplateResponse(request, 'power.html', {'title': _('Power')})
def restart(request):
"""Serve start confirmation page."""
form = None
if request.method == 'POST':
actions.superuser_run('power', ['restart'], async=True)
return redirect(reverse('apps:index'))
else:
form = Form(prefix='power')
return TemplateResponse(request, 'power_restart.html',
{'title': _('Power'),
'form': form})
def shutdown(request):
"""Serve shutdown confirmation page."""
form = None
if request.method == 'POST':
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'),
'form': form})