names: Use AppView for app page

Tests:

- App page shows properly. Status of the current domains is shown properly.

- App page does not show enable/disable button.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-08-19 16:34:42 -07:00 committed by James Valleroy
parent b970b72bb0
commit 6bd9211791
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 14 additions and 11 deletions

View File

@ -34,6 +34,8 @@ class NamesApp(app_module.App):
_version = 1
can_be_disabled = False
def __init__(self):
"""Create components for the app."""
super().__init__()

View File

@ -8,5 +8,5 @@ from django.urls import re_path
from . import views
urlpatterns = [
re_path(r'^sys/names/$', views.index, name='index'),
re_path(r'^sys/names/$', views.NamesAppView.as_view(), name='index'),
]

View File

@ -3,21 +3,22 @@
FreedomBox app for name services.
"""
from django.template.response import TemplateResponse
from plinth import app as app_module
from plinth.views import AppView
from . import components
def index(request):
"""Serve name services page."""
status = get_status()
class NamesAppView(AppView):
"""Show names app main page."""
return TemplateResponse(request, 'names.html', {
'app_info': app_module.App.get('names').info,
'status': status
})
app_id = 'names'
template_name = 'names.html'
def get_context_data(self, *args, **kwargs):
"""Add additional context data for template."""
context = super().get_context_data(*args, **kwargs)
context['status'] = get_status()
return context
def get_status():