mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Use POST for reboot/shutdown now
This commit is contained in:
parent
eca36e6f96
commit
a002ca300c
@ -31,21 +31,14 @@
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<form class="form" method="post" action="{% url 'power:reboot' %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="{% trans "Reboot... »" %}"/>
|
||||
</form>
|
||||
|
||||
</br>
|
||||
|
||||
<form class="form" method="post" action="{% url 'power:shutdown' %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="{% trans "Shut Down... »" %}"/>
|
||||
</form>
|
||||
<p>
|
||||
<a class="btn btn-primary btn-md" href="{% url 'power:reboot' %}">
|
||||
{% trans "Reboot..." %}</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a class="btn btn-primary btn-md" href="{% url 'power:shutdown' %}">
|
||||
{% trans "Shut Down..." %}</a>
|
||||
</p>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@ -31,11 +31,14 @@
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<form class="form" method="post" action="{% url 'power:reboot_now' %}">
|
||||
<form class="form" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ form|bootstrap }}
|
||||
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="{% trans "Reboot Now »" %}"/>
|
||||
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@ -31,9 +31,11 @@
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<form class="form" method="post" action="{% url 'power:shutdown_now' %}">
|
||||
<form class="form" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ form|bootstrap }}
|
||||
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="{% trans "Shut Down Now »" %}"/>
|
||||
</form>
|
||||
|
||||
@ -25,7 +25,5 @@ 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/reboot/now$', 'reboot_now', name='reboot_now'),
|
||||
url(r'^sys/power/shutdown$', 'shutdown', name='shutdown'),
|
||||
url(r'^sys/power/shutdown/now$', 'shutdown_now', name='shutdown_now'),
|
||||
)
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
Plinth module for power module.
|
||||
"""
|
||||
|
||||
from django.forms import Form
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@ -33,21 +34,27 @@ def index(request):
|
||||
|
||||
def reboot(request):
|
||||
"""Serve reboot confirmation page."""
|
||||
form = None
|
||||
|
||||
if request.method == 'POST':
|
||||
actions.superuser_run('power', ['reboot'])
|
||||
else:
|
||||
form = Form(prefix='power')
|
||||
|
||||
return TemplateResponse(request, 'power_reboot.html',
|
||||
{'title': _('Power Control')})
|
||||
|
||||
|
||||
def reboot_now(request):
|
||||
"""Reboot the system."""
|
||||
actions.superuser_run('power', ['reboot'])
|
||||
{'title': _('Power Control'),
|
||||
'form': form})
|
||||
|
||||
|
||||
def shutdown(request):
|
||||
"""Serve shutdown confirmation page."""
|
||||
form = None
|
||||
|
||||
if request.method == 'POST':
|
||||
actions.superuser_run('power', ['shutdown'])
|
||||
else:
|
||||
form = Form(prefix='power')
|
||||
|
||||
return TemplateResponse(request, 'power_shutdown.html',
|
||||
{'title': _('Power Control')})
|
||||
|
||||
|
||||
def shutdown_now(request):
|
||||
"""Shutdown the system."""
|
||||
actions.superuser_run('power', ['shutdown'])
|
||||
{'title': _('Power Control'),
|
||||
'form': form})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user