{% load i18n misago_capture %}
<div class="card card-admin-info">
  <div class="card-body">
    <h4 class="card-title">
      {% trans "System checks" context "admin checks title" %}
    </h4>
  </div>
  <div id="admin-version-check" class="card-body border-top">
    <div class="media media-admin-check">
      <div class="media-check-icon">
        <div class="spinner-border" role="status">
          <span class="sr-only">{% trans "Loading..." context "admin version check" %}</span>
        </div>
      </div>
      <div class="media-body">
        <h5>{% trans "Checking Misago version used by the site..." context "admin version check" %}</h5>
        {% blocktrans trimmed context "admin version check" %}
          Version check feature relies on the API operated by the Python Package Index (pypi.org) to retrieve the latest Misago release version.
        {% endblocktrans %}
      </div>
    </div>
  </div>
  {% if not checks.debug.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-danger">
          <span class="fas fa-times"></span>
        </div>
        <div class="media-body">
          <h5>{% trans "The site is running in DEBUG mode." context "admin debug check" %}</h5>
          {% blocktrans trimmed context "admin debug check" %}
            Error pages displayed in DEBUG mode will expose site configuration details like secrets and tokens to all visitors.
            This is MAJOR security risk.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.address.set_address %}
    <div class="card-body border-top">
      <div class="row">
        <div class="col">
          <div class="media media-admin-check">
            <div class="media-check-icon media-check-icon-danger">
              <span class="fas fa-times"></span>
            </div>
            <div class="media-body">
              <h5>{% trans "Forum address is not configured." context "admin site address check" %}</h5>
              {% trans "Links in e-mails sent by Misago will be broken." context "admin site address check" %}
            </div>
          </div>
        </div>
        <div class="col-auto">
          <a href="{% url 'misago:admin:settings:general:index' %}">
            <span class="fas fa-external-link-alt"></span>
          </a>
        </div>
      </div>
    </div>
  {% elif not checks.address.is_ok %}
    <div class="card-body border-top">
      <div class="row">
        <div class="col">
          <div class="media media-admin-check">
            <div class="media-check-icon media-check-icon-warning">
              <span class="fas fa-question"></span>
            </div>
            <div class="media-body">
              <h5>{% trans "Configured forum address appears to be incorrect." context "admin site address check" %}</h5>
              <div class="d-block">
                {% capture trimmed as set_address %}
                  <code>{{ checks.address.set_address }}</code>
                {% endcapture %}
                {% capture trimmed as correct_address %}
                  <code>{{ checks.address.correct_address }}</code>
                {% endcapture %}
                {% blocktrans trimmed with configured_address=set_address|safe correct_address=correct_address|safe context "admin site address check" %}
                  Your forum address is set to {{ configured_address }} while correct value appears to be {{ correct_address }}.
                {% endblocktrans %}
              </div>
              <div>
                {% trans "Links in e-mails sent by Misago may be broken." context "admin site address check" %}
              </div>
            </div>
          </div>
        </div>
        <div class="col-auto">
          <a href="{% url 'misago:admin:settings:general:index' %}">
            <span class="fas fa-external-link-alt"></span>
          </a>
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.https.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-warning">
          <span class="fas fa-question"></span>
        </div>
        <div class="media-body">
          <h5>{% trans "The site is not running over HTTPS." context "admin https check" %}</h5>
          {% blocktrans trimmed context "admin https check" %}
            Browsers may warn users visiting the site about it being insecure. Search engines will lower its position in search results.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.cache.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-danger">
          <span class="fas fa-times"></span>
        </div>
        <div class="media-body">
          <h5>{% trans "Cache is disabled." context "admin cache check" %}</h5>
          {% blocktrans trimmed context "admin cache check" %}
            This will cause degraded performance and increased CPU usage by the site, leading to worse user experience and increased hosting costs.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.data_downloads.is_ok %}
    <div class="card-body border-top">
      <div class="media media-admin-check">
        <div class="media-check-icon media-check-icon-danger">
          <span class="fas fa-times"></span>
        </div>
        <div class="media-body">
          <h5>
            {% blocktrans trimmed count downloads=checks.data_downloads.count context "admin data downloads check" %}
              There is {{ downloads }} unprocessed data download request.
            {% plural %}
              There are {{ downloads }} unprocessed data download requests.
            {% endblocktrans %}
          </h5>
          {% blocktrans trimmed context "admin data downloads check" %}
            Cron task that should process user data download requests is not running.
          {% endblocktrans %}
        </div>
      </div>
    </div>
  {% endif %}
  {% if not checks.inactive_users.is_ok %}
    <div class="card-body border-top">
      <div class="row">
        <div class="col">
          <div class="media media-admin-check">
            <div class="media-check-icon media-check-icon-warning">
              <span class="fas fa-question"></span>
            </div>
            <div class="media-body">
              <h5>
                {% blocktrans trimmed count users=checks.inactive_users.count context "admin inactive users check" %}
                  There is {{ users }} inactive user accounts.
                {% plural %}
                  There are {{ users }} inactive users accounts.
                {% endblocktrans %}
              </h5>
              {% blocktrans trimmed context "admin inactive users check" %}
                The site may be targeted by bots, is not sending activation e-mails, or is not configured to delete inactive user accounts.
              {% endblocktrans %}
            </div>
          </div>
        </div>
        <div class="col-auto">
          <a href="{% url 'misago:admin:users:index' %}?is_inactive=1">
            <span class="fas fa-external-link-alt"></span>
          </a>
        </div>
      </div>
    </div>
  {% endif %}
</div>