Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#595] Admin checks #694

Merged
merged 3 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions backend/src/openarchiefbeheer/conf/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-14 10:46+0100\n"
"POT-Creation-Date: 2025-02-14 16:03+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -1762,6 +1762,34 @@ msgstr "Wachtwoord wijzigen"
msgid "Log out"
msgstr "Afmelden"

#: openarchiefbeheer/templates/admin/index.html:12
msgid "Recent actions"
msgstr "Recente acties"

#: openarchiefbeheer/templates/admin/index.html:13
msgid "My actions"
msgstr "Mijn acties"

#: openarchiefbeheer/templates/admin/index.html:17
msgid "None available"
msgstr "Geen beschikbaar"

#: openarchiefbeheer/templates/admin/index.html:22
msgid "Added:"
msgstr "Toegevoegd:"

#: openarchiefbeheer/templates/admin/index.html:22
msgid "Changed:"
msgstr "Gewijzigd:"

#: openarchiefbeheer/templates/admin/index.html:22
msgid "Deleted:"
msgstr "Verwijderd:"

#: openarchiefbeheer/templates/admin/index.html:32
msgid "Unknown content"
msgstr "Onbekende inhoud"

#: openarchiefbeheer/templates/hijack/contrib/admin/button.html:6
msgid "hijack"
msgstr "overnemen"
Expand Down Expand Up @@ -2118,7 +2146,8 @@ msgstr "De selectielijst service ontbreekt in de API configuratie."
#: openarchiefbeheer/config/health_checks.py:86
msgid "No source organisation for the destruction report case configured."
msgstr ""
"Geen bronorganisatie is ingesteld voor de zaak van de verklaring van vernietiging."
"Geen bronorganisatie is ingesteld voor de zaak van de verklaring van "
"vernietiging."

#: openarchiefbeheer/config/health_checks.py:92
msgid "No zaaktype for the destruction report case configured."
Expand All @@ -2127,11 +2156,14 @@ msgstr ""

#: openarchiefbeheer/config/health_checks.py:98
msgid "No selectielijstklasse for the destruction report case configured."
msgstr "Geen selectielijstklasse is ingesteld voor de zaak van de verklaring van vernietiging."
msgstr ""
"Geen selectielijstklasse is ingesteld voor de zaak van de verklaring van "
"vernietiging."

#: openarchiefbeheer/config/health_checks.py:105
msgid "No informatieobjecttype for the destruction report document configured."
msgstr "Geen informatieobjecttype is ingesteld voor de verklaring van vernietiging."
msgstr ""
"Geen informatieobjecttype is ingesteld voor de verklaring van vernietiging."

#: openarchiefbeheer/config/models.py:11
msgid "zaaktypes short process"
Expand Down Expand Up @@ -2201,3 +2233,23 @@ msgstr "API-configuratie"
#: openarchiefbeheer/config/models.py:88
msgid "API configurations"
msgstr "API-configuraties"

#: openarchiefbeheer/config/templates/configuration_health_check.html:5
msgid "Configuration status"
msgstr "Configuratie status"

#: openarchiefbeheer/config/templates/configuration_health_check.html:8
msgid "Configuration complete"
msgstr "Configuratie voltooid"

#: openarchiefbeheer/config/templates/configuration_health_check.html:10
msgid "Configuration incomplete"
msgstr "Configuratie onvoltooid"

#: openarchiefbeheer/config/templates/configuration_health_check.html:14
msgid "The configuration is complete."
msgstr "De configuratie is voltooid."

#: openarchiefbeheer/config/templates/configuration_health_check.html:16
msgid "The following issues have been detected:"
msgstr "De volgende problemen zijn ontdekt:"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% load i18n %}

<div>
<h2>
{% translate 'Configuration status' %}
&nbsp;
{% if success %}
<img src="/static/admin/img/icon-yes.svg" alt="{% translate 'Configuration complete' %}">
{% else %}
<img src="/static/admin/img/icon-no.svg" alt="{% translate 'Configuration incomplete' %}">
{% endif %}
</h2>
{% if success %}
<p>{% translate 'The configuration is complete.' %}</p>
{% else %}
<p>{% translate 'The following issues have been detected:' %}</p>
<ul class="config-error-list">
{% for error in errors %}
<li>{{ error.message }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django import template

from ..health_checks import is_configuration_complete

register = template.Library()


@register.inclusion_tag("configuration_health_check.html")
def configuration_health_check():
result = is_configuration_complete()
return result
20 changes: 20 additions & 0 deletions backend/src/openarchiefbeheer/config/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.urls import reverse

from django_webtest import WebTest
from maykin_2fa.test import disable_admin_mfa

from openarchiefbeheer.accounts.tests.factories import UserFactory


class HealthCheckTests(WebTest):
@disable_admin_mfa()
def test_health_check(self):
user = UserFactory.create(superuser=True)
url = reverse("admin:index")

response = self.app.get(url, user=user)

self.assertEqual(response.status_code, 200)
self.assertEqual(
len(response.html.find_all(id="configuration-health-check")), 1
)
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,70 @@ div.breadcrumbs a:focus, div.breadcrumbs a:hover {
color: var(--primary) !important;
}

.admin-sidebar {
float: right;
width: 260px;
position: relative;
margin-right: -300px;
}

.colSM .admin-sidebar {
float: left;
margin-right: 0;
margin-left: -300px;
}

.admin-sidebar .admin-sidebar-item {
background: var(--darkened-bg);
padding-bottom: 16px;
margin-bottom: 16px;
margin-top: 0;
}

.admin-sidebar .admin-sidebar-item .config-error-list {
padding: 0 16px;
margin: 16px;
}

.admin-sidebar h2 {
background: none;
padding: 16px;
margin: 0 0 16px 0;
border-bottom: 1px solid var(--hairline-color);
font-size: 1.125rem;
color: var(--body-fg);
font-weight: 400;
}

.admin-sidebar h3 {
color: var(--body-quiet-color);
padding: 0 16px;
margin: 0 0 16px;
}

.admin-sidebar h4 {
font-size: 0.8125rem;
}

.admin-sidebar p {
padding-left: 16px;
padding-right: 16px;
}

.admin-sidebar .actionlist {
padding: 0;
margin: 16px;
}

.admin-sidebar .actionlist li {
line-height: 1.2;
margin-bottom: 10px;
padding-left: 18px;
}




/* Calendar & time widget */
.calendar caption,
.calendarbox h2 {
Expand Down
42 changes: 42 additions & 0 deletions backend/src/openarchiefbeheer/templates/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends "admin/index.html" %}
{% load configuration_health_check static i18n %}

{% block sidebar %}
<div class="admin-sidebar">
<div class="admin-sidebar-item" id="configuration-health-check">
{% configuration_health_check %}
</div>

<!-- Overwriting the parent template -->
<div class="admin-sidebar-item" id="recent-actions-module">
<h2>{% translate 'Recent actions' %}</h2>
<h3>{% translate 'My actions' %}</h3>
{% load log %}
{% get_admin_log 10 as admin_log for_user user %}
{% if not admin_log %}
<p>{% translate 'None available' %}</p>
{% else %}
<ul class="actionlist">
{% for entry in admin_log %}
<li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
<span class="visually-hidden">{% if entry.is_addition %}{% translate 'Added:' %}{% elif entry.is_change %}{% translate 'Changed:' %}{% elif entry.is_deletion %}{% translate 'Deleted:' %}{% endif %}</span>
{% if entry.is_deletion or not entry.get_admin_url %}
{{ entry.object_repr }}
{% else %}
<a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
{% endif %}
<br>
{% if entry.content_type %}
<span class="mini quiet">{% filter capfirst %}{{ entry.content_type.name }}{% endfilter %}</span>
{% else %}
<span class="mini quiet">{% translate 'Unknown content' %}</span>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>


{% endblock %}