feat: Add overview of missing texts

This commit is contained in:
moanos [he/him] 2024-09-29 00:20:08 +02:00
parent cabb7f7181
commit b8fe6b6655
2 changed files with 48 additions and 10 deletions

View File

@ -1,15 +1,37 @@
{% extends "fellchensammlung/base_generic.html" %}
{% load i18n %}
{% block content %}
<div class="card">
<h1>{% translate "Instanz-Check" %}</h1>
<p>{% translate "Nicht-lokalisierte Vermittlungen" %}: {{ number_not_geocoded_adoption_notices }}/{{ number_of_adoption_notices }}</p>
<p>{% translate "Nicht-lokalisierte Tierschutzorganisationen" %}: {{ number_not_geocoded_rescue_orgs }}/{{ number_of_rescue_orgs }}</p>
{% if missing_texts|length > 0 %}
<h2>{% trans "Fehlende Texte" %}</h2>
<p>
<table>
<tr>
<th>{% translate "Text Code" %}</th>
<th>{% translate "Sprache" %}</th>
</tr>
{% for missing_text in missing_texts %}
<tr>
<td>{{ missing_text.0 }}</td>
<td>{{ missing_text.1 }}</td>
</tr>
{% endfor %}
</table>
</p>
{% else %}
<p>{% translate "Texte scheinen vollständig" %}</p>
{% endif %}
<h2>{% translate "Nicht-lokalisierte Vermittlungen" %}</h2>
<p>{{ number_not_geocoded_adoption_notices }}/{{ number_of_adoption_notices }}</p>
<h2>{% translate "Nicht-lokalisierte Tierschutzorganisationen" %}</h2>
<p>{{ number_not_geocoded_rescue_orgs }}/{{ number_of_rescue_orgs }}</p>
<form class="notification-card-mark-read" method="post">
{% csrf_token %}
<input type="hidden" name="action" value="clean_locations">
<button class="btn" type="submit" id="submit">
<i class="fa-solid fa-broom"></i> {% translate "Erneut lokalisieren" %}
</button>
</form>
</div>
<form class="notification-card-mark-read" method="POST">
{% csrf_token %}
<input type="hidden" name="action" value="clean_locations">
<button class="btn2" type="submit" id="submit"><i class="fa-solid fa-broom"></i> {% translate "Erneut lokalisieren" %}</button>
</form>
{% endblock %}
{% endblock content %}

View File

@ -428,12 +428,28 @@ def instance_health_check(request):
number_of_rescue_orgs = RescueOrganization.objects.all().count()
number_not_geocoded_rescue_orgs = RescueOrganization.objects.filter(location__isnull=True).count()
# CHECK FOR MISSING TEXTS
languages = Language.objects.all()
texts = Text.objects.all()
text_codes = set([text.text_code for text in texts])
missing_texts = []
for language in languages:
for text_code in text_codes:
try:
Text.objects.get(text_code=text_code, language=language)
except Text.DoesNotExist:
missing_texts.append((text_code, language))
context = {
"number_of_adoption_notices": number_of_adoption_notices,
"number_not_geocoded_adoption_notices": number_not_geocoded_adoption_notices,
"number_of_rescue_orgs": number_of_rescue_orgs,
"number_not_geocoded_rescue_orgs": number_not_geocoded_rescue_orgs
"number_not_geocoded_rescue_orgs": number_not_geocoded_rescue_orgs,
"missing_texts": missing_texts
}
return render(request, 'fellchensammlung/instance-health-check.html', context=context)