mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
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:
parent
9b6774f279
commit
493071bfe0
@ -50,6 +50,8 @@ class LetsEncryptApp(app_module.App):
|
|||||||
|
|
||||||
_version = 3
|
_version = 3
|
||||||
|
|
||||||
|
can_be_disabled = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Create components for the app."""
|
"""Create components for the app."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|||||||
@ -8,7 +8,8 @@ from django.urls import re_path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
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,
|
re_path(r'^sys/letsencrypt/obtain/(?P<domain>[^/]+)/$', views.obtain,
|
||||||
name='obtain'),
|
name='obtain'),
|
||||||
re_path(r'^sys/letsencrypt/re-obtain/(?P<domain>[^/]+)/$', views.reobtain,
|
re_path(r'^sys/letsencrypt/re-obtain/(?P<domain>[^/]+)/$', views.reobtain,
|
||||||
|
|||||||
@ -7,30 +7,28 @@ import logging
|
|||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.template.response import TemplateResponse
|
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
|
|
||||||
from plinth import app as app_module
|
|
||||||
from plinth.errors import ActionError
|
from plinth.errors import ActionError
|
||||||
from plinth.modules import letsencrypt
|
from plinth.modules import letsencrypt
|
||||||
|
from plinth.views import AppView
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
class LetsEncryptAppView(AppView):
|
||||||
"""Serve configuration page."""
|
"""Show Let's Encrypt app main page."""
|
||||||
status = letsencrypt.get_status()
|
|
||||||
app = app_module.App.get('letsencrypt')
|
app_id = 'letsencrypt'
|
||||||
return TemplateResponse(
|
template_name = 'letsencrypt.html'
|
||||||
request, 'letsencrypt.html', {
|
|
||||||
'app_id': 'letsencrypt',
|
def get_context_data(self, *args, **kwargs):
|
||||||
'app_info': app.info,
|
"""Add additional context data for template."""
|
||||||
'status': status,
|
context = super().get_context_data(*args, **kwargs)
|
||||||
'has_diagnostics': True,
|
context['status'] = letsencrypt.get_status()
|
||||||
'is_enabled': app.is_enabled(),
|
return context
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user