diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b8edc13c13aa3b760eecf77254c689b85cc3fcec..34493619ea439077184282acf4eb388d193642bb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,7 @@ Added ~~~~~ * GraphQL schema for Rooms +* Provide API endpoint for system status. * [Dev] UpdateIndicator Vue Component to display the status of interactive pages * [Dev] DeleteDialog Vue Component to unify item deletion in the new frontend @@ -38,6 +39,7 @@ Fixed * When the Celery worker wasn't able to execute all tasks in time, notifications were sent multiple times. * Changing the maintenance mode state spawned another SPA instance in the iframe * Phone numbers couldn't be in regional format. +* System status view wasn't accessible through new frontend if a check failed. `3.0b3`_ - 2023-03-19 --------------------- diff --git a/aleksis/core/urls.py b/aleksis/core/urls.py index 29fe9dcb2f5e51d0c1461898efae087ac9c6ee27..48890c43fec514d539811599b11c6e0da103d5db 100644 --- a/aleksis/core/urls.py +++ b/aleksis/core/urls.py @@ -38,6 +38,7 @@ urlpatterns = [ "oauth/authorized_tokens/", views.TemplateView.as_view(template_name="core/vue_index.html") ), path("oauth/", include("oauth2_provider.urls", namespace="oauth2_provider")), + path("system_status/", views.SystemStatusAPIView.as_view(), name="system_status_api"), path( "django/", include( diff --git a/aleksis/core/views.py b/aleksis/core/views.py index 3fd874f4f920ca871083c34a11e921e6181742b3..10f10b0fc3057be64c1fe80fcc7d6ac1c5732ce7 100644 --- a/aleksis/core/views.py +++ b/aleksis/core/views.py @@ -493,7 +493,6 @@ class SystemStatus(PermissionRequiredMixin, MainView): context = {} def get(self, request, *args, **kwargs): - status_code = 500 if self.errors else 200 task_results = [] if app.control.inspect().registered_tasks(): @@ -505,12 +504,11 @@ class SystemStatus(PermissionRequiredMixin, MainView): context = { "plugins": self.plugins, - "status_code": status_code, "tasks": task_results, "DEBUG": settings.DEBUG, "form": MaintenanceModeForm(), } - return self.render_to_response(context, status=status_code) + return self.render_to_response(context) def post(self, request, *args, **kwargs): form = MaintenanceModeForm(request.POST) @@ -532,6 +530,18 @@ class SystemStatus(PermissionRequiredMixin, MainView): return self.get(request, *args, **kwargs) +class SystemStatusAPIView(PermissionRequiredMixin, MainView): + """Provide information about system status as JSON.""" + + permission_required = "core.view_system_status_rule" + + @method_decorator(never_cache) + def get(self, request, *args, **kwargs): + status_code = 500 if self.errors else 200 + + return self.render_to_response_json(self.plugins, status_code) + + class TestPDFGenerationView(PermissionRequiredMixin, RenderPDFView): template_name = "core/pages/test_pdf.html" permission_required = "core.test_pdf_rule"