{% extends 'admin/master.html' %} {% block head_css %} {{ super() }} {% endblock %} {# Badge helper macro #} {% macro badge_status(condition, true_text, false_text, true_class='success', false_class='danger') -%} {% if condition %} {{ true_text }} {% else %} {{ false_text }} {% endif %} {%- endmacro %} {% macro copy_btn(text) -%} {%- endmacro %} {# User summary card with link to email search #} {% macro user_summary_card(user) -%}
Domain Owner
User
{{ user.email }}
ID: {{ user.id }}
Status
{{ badge_status(user.activated, 'Verified', 'Pending', 'success', 'warning') }} {{ badge_status(not user.disabled, 'Enabled', 'Disabled', 'success', 'danger') }}
Subscription
{{ badge_status(user.is_premium() , 'Premium', 'Free', 'info', 'secondary') }}
Created
{{ user.created_at.strftime("%Y-%m-%d") }}
Custom Domains
{{ user.custom_domains|length }} domain(s)
{%- endmacro %} {# Verification status badge #} {% macro verification_badge(is_verified, label) -%} {% if is_verified %} {{ label }} Verified {% else %} {{ label }} Pending {% endif %} {%- endmacro %} {# DNS record display #} {% macro dns_record_display(label, expected, validation_errors) -%}
{{ label }} {% if not expected %} Verified {% else %} Pending {% endif %}
{% if expected %}
Expected Record:
{{ expected.recommended }}
{% if expected.allowed and expected.allowed|length > 1 %}
Alternative accepted values ({{ expected.allowed|length }})
{% endif %} {% if validation_errors %}
Current DNS Response: {% for error in validation_errors %}
{{ error or 'No record found' }}
{% endfor %}
{% endif %} {% endif %}
{%- endmacro %} {# MX record display (special handling for priorities) #} {% macro mx_record_display(expected, validation_errors) -%}
MX Records {% if not expected %} Verified {% else %} Pending {% endif %}
{% if expected %}
Expected Records: {% for priority in expected|sort %}
Priority {{ priority }} {{ expected[priority].recommended }}
{% endfor %}
{% if validation_errors %}
Current DNS Response: {% for error in validation_errors %}
{{ error or 'No record found' }}
{% endfor %}
{% endif %} {% endif %}
{%- endmacro %} {# DKIM records display #} {% macro dkim_records_display(domain, dkim_expected, dkim_validation) -%}
DKIM Records {% if not dkim_expected %} Verified {% else %} Pending {% endif %}
{% if dkim_expected %} {% for dkim_selector in dkim_expected %} {% set full_domain = dkim_selector + "." + domain.domain %}
Selector: {{ full_domain }}
{{ dkim_expected[dkim_selector].recommended }}
{% if dkim_validation.get(full_domain) %} Current:
{{ dkim_validation.get(full_domain) or 'No record found' }}
{% endif %}
{% endfor %} {% endif %}
{%- endmacro %} {# Verification status summary inline #} {% macro verification_summary(domain) -%} {% set verified_count = (domain.ownership_verified|int) + (domain.verified|int) + (domain.spf_verified|int) + (domain.dkim_verified|int) + (domain.dmarc_verified|int) %} {% set total_count = 5 %} {% if verified_count == total_count %} All Verified ({{ verified_count }}/{{ total_count }}) {% elif verified_count == 0 %} Not Verified (0/{{ total_count }}) {% else %} Partial ({{ verified_count }}/{{ total_count }}) {% endif %} {%- endmacro %} {# Domain card #} {% macro domain_card(domain_data) -%} {% set domain = domain_data.domain %}
{{ domain.domain }}{{ copy_btn(domain.domain) }} {% if domain.pending_deletion %}Pending Deletion{% endif %}
ID: {{ domain.id }}
{# Domain Owner Summary #} {{ user_summary_card(domain.user) }} {# Domain Information + Actions Row #}
{# Domain Information - 3/4 width #}
Domain Information
{# Row 1: Details & Settings #}
Details
{% if domain.name %} {% endif %}
ID: {{ domain.id }}
Domain: {{ domain.domain }}{{ copy_btn(domain.domain) }}
Name: {{ domain.name }}
Created: {{ domain.created_at.strftime("%Y-%m-%d %H:%M") }}
Aliases: {{ helper.alias_count(domain) }}
Settings
Catch-All: {{ badge_status(domain.catch_all, 'Enabled', 'Disabled', 'info', 'secondary') }}
Random Prefix: {{ badge_status(domain.random_prefix_generation, 'Enabled', 'Disabled', 'info', 'secondary') }}
SL Subdomain: {{ badge_status(domain.is_sl_subdomain, 'Yes', 'No', 'info', 'secondary') }}
Failed Checks: {% if domain.nb_failed_checks > 0 %} {{ domain.nb_failed_checks }} {% else %} 0 {% endif %}
{# Row 2: Verification Status #}
Verification Status {{ verification_summary(domain) }}
{{ verification_badge(domain.ownership_verified, 'Ownership') }} {{ verification_badge(domain.verified, 'MX') }} {{ verification_badge(domain.spf_verified, 'SPF') }} {{ verification_badge(domain.dkim_verified, 'DKIM') }} {{ verification_badge(domain.dmarc_verified, 'DMARC') }}
{# Admin Actions - 1/4 width #}
Actions Caution
{% if not domain.pending_deletion %} {# Spacer to push delete to bottom #}
{# Delete Domain - fixed at bottom like a footer #}
{% else %}

Pending deletion

{% endif %}
{# DNS Records Section #}
DNS Records
{{ dns_record_display('Ownership (TXT)', domain_data.ownership_expected, domain_data.ownership_validation.errors if domain_data.ownership_validation else []) }} {{ dns_record_display('SPF (TXT)', domain_data.spf_expected, domain_data.spf_validation.errors if domain_data.spf_validation else []) }}
{{ mx_record_display(domain_data.mx_expected, domain_data.mx_validation.errors if domain_data.mx_validation else []) }} {{ dkim_records_display(domain, domain_data.dkim_expected, domain_data.dkim_validation) }}
{# Aliases Section #} {% set alias_count = helper.alias_count(domain) %} {% set aliases = helper.alias_list(domain) %} {% set deleted_alias_count = helper.deleted_alias_count(domain) %} {% set deleted_aliases = helper.deleted_alias_list(domain) %}
Aliases {{ alias_count }} total {% if alias_count > 10 %}(showing 10){% endif %}
{% if aliases %}
{% for alias in aliases %} {% endfor %}
ID Email Enabled Created
{{ alias.id }} {{ alias.email }} {{ badge_status(alias.enabled, 'Yes', 'No', 'success', 'danger') }} {{ alias.created_at.strftime("%Y-%m-%d %H:%M") }}
{% else %}
No aliases
{% endif %}
Deleted Aliases {{ deleted_alias_count }} total {% if deleted_alias_count > 10 %}(showing 10){% endif %}
{% if deleted_aliases %}
{% for deleted in deleted_aliases %} {% endfor %}
ID Email Deleted At
{{ deleted.id }} {{ deleted.email }} {{ deleted.created_at.strftime("%Y-%m-%d %H:%M") }}
{% else %}
No deleted aliases
{% endif %}
{# Delete Domain Modal #} {% if not domain.pending_deletion %} {% endif %} {%- endmacro %} {% block body %}
{# Search Form #}
Custom Domain Search
Search by domain name, user email, user ID, or use POSIX regex patterns (limited to 10 results).
{# No Results Alert #} {% if data.no_match and query %} {% endif %} {# Regex Match Notice #} {% if data.found_by_regex and data.domains %} {% endif %} {# Domain Results #} {% for domain_data in data.domains %}{{ domain_card(domain_data) }}{% endfor %}
{% endblock %}