letsencrypt: Use AppView for app page

Tests:

- Enable/disable button is not shown.

- List of certificates in the system is shown.

- Diagnostics menu item is shown and works.

- Certificate operations work.

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 23:18:06 -07:00 committed by James Valleroy
parent 9b6774f279
commit 493071bfe0
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 16 additions and 15 deletions

View File

@ -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__()

View File

@ -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<domain>[^/]+)/$', views.obtain,
name='obtain'),
re_path(r'^sys/letsencrypt/re-obtain/(?P<domain>[^/]+)/$', views.reobtain,

View File

@ -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