diff --git a/plinth/modules/letsencrypt/__init__.py b/plinth/modules/letsencrypt/__init__.py index a0ae8fd2b..76b067e10 100644 --- a/plinth/modules/letsencrypt/__init__.py +++ b/plinth/modules/letsencrypt/__init__.py @@ -50,6 +50,8 @@ class LetsEncryptApp(app_module.App): _version = 3 + can_be_disabled = False + def __init__(self): """Create components for the app.""" super().__init__() diff --git a/plinth/modules/letsencrypt/urls.py b/plinth/modules/letsencrypt/urls.py index 1934ff167..764eb922e 100644 --- a/plinth/modules/letsencrypt/urls.py +++ b/plinth/modules/letsencrypt/urls.py @@ -8,7 +8,8 @@ from django.urls import re_path from . import views urlpatterns = [ - re_path(r'^sys/letsencrypt/$', views.index, name='index'), + re_path(r'^sys/letsencrypt/$', views.LetsEncryptAppView.as_view(), + name='index'), re_path(r'^sys/letsencrypt/obtain/(?P[^/]+)/$', views.obtain, name='obtain'), re_path(r'^sys/letsencrypt/re-obtain/(?P[^/]+)/$', views.reobtain, diff --git a/plinth/modules/letsencrypt/views.py b/plinth/modules/letsencrypt/views.py index b9b215b6f..f6b9906f1 100644 --- a/plinth/modules/letsencrypt/views.py +++ b/plinth/modules/letsencrypt/views.py @@ -7,30 +7,28 @@ import logging from django.contrib import messages from django.shortcuts import redirect -from django.template.response import TemplateResponse from django.urls import reverse_lazy from django.utils.translation import gettext as _ from django.views.decorators.http import require_POST -from plinth import app as app_module from plinth.errors import ActionError from plinth.modules import letsencrypt +from plinth.views import AppView logger = logging.getLogger(__name__) -def index(request): - """Serve configuration page.""" - status = letsencrypt.get_status() - app = app_module.App.get('letsencrypt') - return TemplateResponse( - request, 'letsencrypt.html', { - 'app_id': 'letsencrypt', - 'app_info': app.info, - 'status': status, - 'has_diagnostics': True, - 'is_enabled': app.is_enabled(), - }) +class LetsEncryptAppView(AppView): + """Show Let's Encrypt app main page.""" + + app_id = 'letsencrypt' + template_name = 'letsencrypt.html' + + def get_context_data(self, *args, **kwargs): + """Add additional context data for template.""" + context = super().get_context_data(*args, **kwargs) + context['status'] = letsencrypt.get_status() + return context @require_POST