From 6bd9211791d0dbb2a4bd3fc1511d1bea73eb197b Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 19 Aug 2022 16:34:42 -0700 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- plinth/modules/names/__init__.py | 2 ++ plinth/modules/names/urls.py | 2 +- plinth/modules/names/views.py | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/plinth/modules/names/__init__.py b/plinth/modules/names/__init__.py index 07c9e06e7..f06913e77 100644 --- a/plinth/modules/names/__init__.py +++ b/plinth/modules/names/__init__.py @@ -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__() diff --git a/plinth/modules/names/urls.py b/plinth/modules/names/urls.py index bc2b936ee..63e6f0787 100644 --- a/plinth/modules/names/urls.py +++ b/plinth/modules/names/urls.py @@ -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'), ] diff --git a/plinth/modules/names/views.py b/plinth/modules/names/views.py index 4c0cb51d6..736d4116a 100644 --- a/plinth/modules/names/views.py +++ b/plinth/modules/names/views.py @@ -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():