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