{% load i18n %}

{% if not domain.enable_dns_checks or domain.uses_a_reserved_tld %}
  <span class="label label-mini label-default">{% trans "Disabled" context "checks" %}</span>
{% elif domain.awaiting_checks %}
  <span class="label label-mini label-info">{% trans "Awaiting checks" %}</span>
{% else %}
  {% if enable_mx_checks %}
    <span class="label label-mini label-{% if not domain.mxrecord_set.has_valids %}danger{% else %}success{% endif %}"><a href="{% url 'admin:mx_domain_detail' domain.pk %}" data-toggle="ajaxmodal">MX</a></span>
  {% endif %}
  {% if enable_dnsbl_checks %}
    <span class="label label-mini label-{{ domain.dnsbl_status_color }}"><a href="{% url 'admin:dnsbl_domain_detail' domain.pk %}" data-toggle="ajaxmodal">DNSBL</a></span>
  {% endif %}
  {% if enable_spf_checks %}
    {% if not domain.spf_record %}
      <span class="label label-mini label-danger" title="{% trans 'No record found' %}">SPF</span>
    {% else %}
      <span class="label label-mini label-{% if not domain.spf_record.is_valid %}warning{% else %}success{% endif %}">
        <a href="{% url 'dnstools:dns_record_detail' domain.spf_record.pk %}" data-toggle="ajaxmodal">SPF</a></span>
    {% endif %}
  {% endif %}
  {% if enable_dkim_checks and domain.enable_dkim %}
    {% if not domain.dkim_public_key %}
      <span class="label label-mini label-default" title="{% trans 'Waiting for key to be generated' %}">DKIM</span>
    {% elif not domain.dkim_record %}
      <span class="label label-mini label-danger" title="{% trans 'No record found' %}">DKIM</span>
    {% else %}
      <span class="label label-mini label-{% if not domain.dkim_record %}danger{% elif not domain.dkim_record.is_valid %}warning{% else %}success{% endif %}">
        <a href="{% url 'dnstools:dns_record_detail' domain.dkim_record.pk %}" data-toggle="ajaxmodal">DKIM</a></span>
    {% endif %}
  {% endif %}
  {% if enable_dmarc_checks %}
    {% if not domain.dmarc_record %}
      <span class="label label-mini label-danger" title="{% trans 'No record found' %}">DMARC</span>
    {% else %}      
      <span class="label label-mini label-{% if not domain.dmarc_record.is_valid %}warning{% else %}success{% endif %}">
        <a href="{% url 'dnstools:dns_record_detail' domain.dmarc_record.pk %}" data-toggle="ajaxmodal">DMARC</a></span>
    {% endif %}
  {% endif %}
  {% if enable_autoconfig_checks %}
    {% if not domain.autoconfig_record and not domain.autodiscover_record %}
      <span class="label label-mini label-danger" title="{% trans 'No record found' %}">autoconfig</span>
    {% elif not domain.autoconfig_record or not domain.autodiscover_record %}
      <span class="label label-mini label-warning"><a href="{% url 'dnstools:autoconfig_records_status' domain.pk %}" data-toggle="ajaxmodal">autoconfig</a></span>
    {% else %}
      <span class="label label-mini label-success"><a href="{% url 'dnstools:autoconfig_records_status' domain.pk %}" data-toggle="ajaxmodal">autoconfig</a></span>
    {% endif %}
  {% endif %}
{% endif %}
