mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
power: Use AppView for app page
Tests: - Enable/disable button is not shown. - Diagnostics menu item is not shown. - If apt is busy a warning message is shown. - Restart and Shutdown buttons are shown and work. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
0d0c417bcd
commit
a7eb5e8f0e
@ -21,6 +21,8 @@ class PowerApp(app_module.App):
|
||||
|
||||
_version = 1
|
||||
|
||||
can_be_disabled = False
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
|
||||
@ -8,7 +8,7 @@ from django.urls import re_path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
re_path(r'^sys/power/$', views.index, name='index'),
|
||||
re_path(r'^sys/power/$', views.PowerAppView.as_view(), name='index'),
|
||||
re_path(r'^sys/power/restart$', views.restart, name='restart'),
|
||||
re_path(r'^sys/power/shutdown$', views.shutdown, name='shutdown'),
|
||||
]
|
||||
|
||||
@ -11,17 +11,20 @@ from django.urls import reverse
|
||||
from plinth import actions
|
||||
from plinth import app as app_module
|
||||
from plinth import package
|
||||
from plinth.views import AppView
|
||||
|
||||
|
||||
def index(request):
|
||||
"""Serve power controls page."""
|
||||
app = app_module.App.get('power')
|
||||
return TemplateResponse(
|
||||
request, 'power.html', {
|
||||
'title': app.info.name,
|
||||
'app_info': app.info,
|
||||
'pkg_manager_is_busy': package.is_package_manager_busy()
|
||||
})
|
||||
class PowerAppView(AppView):
|
||||
"""Show power app main page."""
|
||||
|
||||
app_id = 'power'
|
||||
template_name = 'power.html'
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
"""Add additional context data for template."""
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context['pkg_manager_is_busy'] = package.is_package_manager_busy()
|
||||
return context
|
||||
|
||||
|
||||
def restart(request):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user