mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #916 from tonioo/refactor/dns_settings
Refactor: Dns settings
This commit is contained in:
@@ -69,7 +69,8 @@ class AdminParametersForm(parameters.AdminParametersForm):
|
||||
"of the MX that should match with domains' MX records. "
|
||||
"On per line."
|
||||
),
|
||||
widget=forms.Textarea
|
||||
widget=forms.Textarea,
|
||||
required=False
|
||||
)
|
||||
|
||||
enable_dnsbl_checks = YesNoField(
|
||||
@@ -126,6 +127,7 @@ class AdminParametersForm(parameters.AdminParametersForm):
|
||||
|
||||
# Visibility rules
|
||||
visibility_rules = {
|
||||
"valid_mxs": "enable_mx_checks=yes",
|
||||
"mailboxes_owner": "handle_mailboxes=yes",
|
||||
}
|
||||
|
||||
|
||||
@@ -229,9 +229,8 @@ class MXQuerySet(models.QuerySet):
|
||||
|
||||
def has_valids(self):
|
||||
"""Return managed results."""
|
||||
if parameters.get_admin("ENABLE_MX_CHECKS"):
|
||||
if parameters.get_admin("VALID_MXS", app="admin").strip():
|
||||
return self.filter(managed=True).exists()
|
||||
if parameters.get_admin("VALID_MXS", app="admin").strip():
|
||||
return self.filter(managed=True).exists()
|
||||
return self.exists()
|
||||
|
||||
|
||||
|
||||
@@ -21,11 +21,17 @@
|
||||
<h3 class="panel-title">{% trans "Summary" %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<span class="title">{% trans "DNS status" %}</span>
|
||||
<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>
|
||||
<span class="label label-{{ domain.dnsbl_status_color }}"><a href="{% url 'admin:dnsbl_domain_detail' domain.pk %}" data-toggle="ajaxmodal">DNSBL</a></span>
|
||||
</div>
|
||||
{% if enable_mx_checks == "yes" or enable_dnsbl_checks == "yes" %}
|
||||
<div class="row">
|
||||
<span class="title">{% trans "DNS status" %}</span>
|
||||
{% if enable_mx_checks == "yes" %}
|
||||
<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 == "yes" %}
|
||||
<span class="label label-{{ domain.dnsbl_status_color }}"><a href="{% url 'admin:dnsbl_domain_detail' domain.pk %}" data-toggle="ajaxmodal">DNSBL</a></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<span class="title">{% trans "Creation date" %}</span><span>{{ domain.creation }}</span>
|
||||
</div>
|
||||
|
||||
@@ -31,9 +31,11 @@ $(document).ready(function() {
|
||||
{% block actions %}{% domains_menu "domains" user %}{% endblock %}
|
||||
|
||||
{% block table_header %}
|
||||
<th id="name" class="sortable" data-sort_order="name" width="">{% trans "Name" %}</th>
|
||||
<th id="aliases" width="">{% trans "Alias(es)" %}</th>
|
||||
<th id="tags" class="sortable" data-sort_order="tags" width="">{% trans "Tags" %}</th>
|
||||
<th id="tags" width="">{% trans "DNS status" %}</th>
|
||||
<th id="actions" width="">{% trans "Actions" %}</th>
|
||||
<th id="name" class="sortable" data-sort_order="name" width="">{% trans "Name" %}</th>
|
||||
<th id="aliases" width="">{% trans "Alias(es)" %}</th>
|
||||
<th id="tags" class="sortable" data-sort_order="tags" width="">{% trans "Tags" %}</th>
|
||||
{% if enable_mx_checks == "yes" or enable_dnsbl_checks == "yes" %}
|
||||
<th id="dns" width="">{% trans "DNS status" %}</th>
|
||||
{% endif %}
|
||||
<th id="actions" width="">{% trans "Actions" %}</th>
|
||||
{% endblock %}
|
||||
|
||||
@@ -5,12 +5,18 @@
|
||||
<td name="name"><a href="{% url 'admin:domain_detail' domain.id %}">{{ domain }}</a>{% if not domain.enabled %} ({% trans "disabled" %}){% endif %}</td>
|
||||
<td name="aliases">{% domain_aliases domain %} </td>
|
||||
<td name="tags">{% render_tags domain.tags %}</td>
|
||||
<td name="auth">
|
||||
<small>
|
||||
<span class="label label-mini label-{% if not domain.mxrecord_set.exists %}danger{% else %}success{% endif %}"><a href="{% url 'admin:mx_domain_detail' domain.pk %}" data-toggle="ajaxmodal">MX</a></span>
|
||||
<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>
|
||||
</small>
|
||||
</td>
|
||||
{% if enable_mx_checks == "yes" or enable_dnsbl_checks == "yes" %}
|
||||
<td name="dns">
|
||||
<small>
|
||||
{% if enable_mx_checks == "yes" %}
|
||||
<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 == "yes" %}
|
||||
<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 %}
|
||||
</small>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td name="actions">{% domain_actions user domain %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -63,7 +63,7 @@ def _domains(request):
|
||||
context = {
|
||||
"handle_mailboxes": parameters.get_admin(
|
||||
"HANDLE_MAILBOXES", raise_error=False),
|
||||
"auto_account_removal": parameters.get_admin("AUTO_ACCOUNT_REMOVAL")
|
||||
"auto_account_removal": parameters.get_admin("AUTO_ACCOUNT_REMOVAL"),
|
||||
}
|
||||
page = get_listing_page(domainlist, request.GET.get("page", 1))
|
||||
if page is None:
|
||||
@@ -71,7 +71,10 @@ def _domains(request):
|
||||
else:
|
||||
context["rows"] = _render_to_string(
|
||||
request, "admin/domains_table.html", {
|
||||
'domains': page.object_list,
|
||||
"domains": page.object_list,
|
||||
"enable_mx_checks": parameters.get_admin("ENABLE_MX_CHECKS"),
|
||||
"enable_dnsbl_checks": (
|
||||
parameters.get_admin("ENABLE_DNSBL_CHECKS")),
|
||||
}
|
||||
)
|
||||
context["pages"] = [page.number]
|
||||
@@ -87,7 +90,11 @@ def domains(request, tplname="admin/domains.html"):
|
||||
reverse("admin:identity_list")
|
||||
)
|
||||
return HttpResponseRedirect(reverse("core:user_index"))
|
||||
return render(request, tplname, {"selection": "domains"})
|
||||
return render(request, tplname, {
|
||||
"selection": "domains",
|
||||
"enable_mx_checks": parameters.get_admin("ENABLE_MX_CHECKS"),
|
||||
"enable_dnsbl_checks": parameters.get_admin("ENABLE_DNSBL_CHECKS")
|
||||
})
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -176,7 +183,11 @@ class DomainDetailView(
|
||||
context = super(DomainDetailView, self).get_context_data(**kwargs)
|
||||
result = signals.extra_domain_dashboard_widgets.send(
|
||||
self.__class__, user=self.request.user, domain=self.object)
|
||||
context["templates"] = {"left": [], "right": []}
|
||||
context.update({
|
||||
"templates": {"left": [], "right": []},
|
||||
"enable_mx_checks": parameters.get_admin("ENABLE_MX_CHECKS"),
|
||||
"enable_dnsbl_checks": parameters.get_admin("ENABLE_DNSBL_CHECKS"),
|
||||
})
|
||||
for receiver, widgets in result:
|
||||
for widget in widgets:
|
||||
context["templates"][widget["column"]].append(
|
||||
|
||||
Reference in New Issue
Block a user