{% extends "fellchensammlung/base.html" %}
{% load i18n %}
{% block title %}<title>{% translate "Instanz-Check" %}</title> {% endblock %}
{% block content %}
    <h1 class="title is-1">{% translate "Instanz-Check" %}</h1>
    {% if missing_texts|length > 0 %}
        <h2 class="title is-2">{% trans "Fehlende Texte" %}</h2>
        <div class="block">
            <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>
        </div>
    {% else %}
        <p>{% translate "Texte scheinen vollständig" %}</p>
    {% endif %}

    <h2 class="title is-2">{% trans "Zeitstempel" %}</h2>
    {% if timestamps|length > 0 %}
        <div class="block">
            <table>
                <tr>
                    <th>{% translate "Key" %}</th>
                    <th>{% translate "Zeitstempel" %}</th>
                    <th>{% translate "Daten" %}</th>
                </tr>
                {% for timestamp in timestamps %}
                    <tr>
                        <td>{{ timestamp.key }}</td>
                        <td>{{ timestamp.timestamp }}</td>
                        <td>{{ timestamp.data }}</td>
                    </tr>
                {% endfor %}
            </table>
        </div>
    {% else %}
        <p>{% translate "Keine Zeitstempel geloggt." %}</p>
    {% endif %}

    <h2 class="title is-2">{% translate "Nicht-lokalisierte Vermittlungen" %}</h2>
    {% if number_not_geocoded_adoption_notices > 0 %}
        <details>
            <summary>{{ number_not_geocoded_adoption_notices }}/{{ number_of_adoption_notices }}</summary>
            <ul>
                {% for adoption_notice in none_geocoded_adoption_notices %}
                    <li>
                        <a href="{{ adoption_notice.get_absolute_url }}">{{ adoption_notice.name }}</a>
                    </li>
                {% endfor %}
            </ul>
        </details>
    {% else %}
        <p>{{ number_not_geocoded_adoption_notices }}/{{ number_of_adoption_notices }}</p>
    {% endif %}

    <h2 class="title is-2">{% translate "Nicht-lokalisierte Tierschutzorganisationen" %}</h2>
    {% if number_not_geocoded_rescue_orgs > 0 %}
        <details>
            <summary>{{ number_not_geocoded_rescue_orgs }}/{{ number_of_rescue_orgs }}</summary>
            <ul>
                {% for rescue_org in none_geocoded_rescue_orgs %}
                    <li>
                        <a href="{{ rescue_org.get_absolute_url }}">{{ rescue_org.name }}</a>
                    </li>
                {% endfor %}
            </ul>
        </details>
    {% else %}
        <p>{{ number_not_geocoded_rescue_orgs }}/{{ number_of_rescue_orgs }}</p>
    {% endif %}

    <h2 class="title is-2">{% translate "Nicht-geprüfte Vermittlungen" %}</h2>
    {% if number_unchecked_ans > 0 %}
        <details>
            <summary>{{ number_unchecked_ans }}</summary>
            <ul>
                {% for unchecked_an in unchecked_ans %}
                    <li>
                        <a href="{{ unchecked_an.get_absolute_url }}">{{ unchecked_an.name }}</a>
                    </li>
                {% endfor %}
            </ul>
        </details>
    {% else %}
        <p>{{ number_unchecked_ans }}</p>
    {% endif %}

    <div class="grid">

        <form class="cell" method="post">
            {% csrf_token %}
            <input type="hidden" name="action" value="clean_locations">
            <button class="button is-primary" type="submit" id="submit">
                <i class="fa-solid fa-location fa-fw"></i> {% translate "Erneut lokalisieren" %}
            </button>
        </form>

        <form class="cell" method="post">
            {% csrf_token %}
            <input type="hidden" name="action" value="deactivate_unchecked_adoption_notices">
            <button class="button is-primary" type="submit" id="submit">
                <i class="fa-solid fa-broom fa-fw"></i> {% translate "Deaktiviere ungeprüfte Vermittlungen" %}
            </button>
        </form>

        <form class="cell" method="post">
            {% csrf_token %}
            <input type="hidden" name="action" value="deactivate_404">
            <button class="button is-primary" type="submit" id="submit">
                <i class="fa-solid fa-broom fa-fw"></i> {% translate "Deaktiviere 404 Vermittlungen" %}
            </button>
        </form>
    </div>
    <div class="block">
        <h2 class="title is-2">{% translate 'Testemail versenden' %}</h2>
        <form method="post">
            {% csrf_token %}
            <input type="hidden" name="action" value="send_test_email">
            <div class="field has-addons">
                <p class="control">
                    {% trans 'E-Mail Addresse an die die Test E-Mail gesendet werden soll' as target_email %}
                    <label hidden="hidden" aria-hidden="false" for="test_email_address">{{ target_email }}</label>
                    <input class="input" id="test_email_address" name="test_email_address" type="text" placeholder="me@example.org">
                </p>
                <p class="control">
                    <button type="submit" class="button is-primary">
                        {% translate 'E-Mail senden testen' %}
                    </button>
                </p>
            </div>
        </form>
    </div>
{% endblock content %}
