mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Added view to display MX records.
This commit is contained in:
@@ -225,6 +225,7 @@ reversion.register(Domain)
|
||||
|
||||
|
||||
class MXRecord(models.Model):
|
||||
"""A model used to store MX records for Domain."""
|
||||
|
||||
domain = models.ForeignKey(Domain)
|
||||
name = models.CharField(max_length=254)
|
||||
|
||||
@@ -34,6 +34,6 @@ $(document).ready(function() {
|
||||
<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 "Authentication" %}</th>
|
||||
<th id="tags" width="">{% trans "DNS status" %}</th>
|
||||
<th id="actions" width="">{% trans "Actions" %}</th>
|
||||
{% endblock %}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<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>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{% extends "common/generic_modal.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block modalbody %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "Address" %}</th>
|
||||
<th>{% trans "Updated" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for mx in domain.mxrecord_set.all %}
|
||||
<tr>
|
||||
<td>{{ mx.name }}</td>
|
||||
<td>{{ mx.address }}</td>
|
||||
<td>{{ mx.updated|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="3">{% trans "No MX record found for this domain." %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
@@ -14,6 +14,8 @@ urlpatterns = patterns(
|
||||
name="domain_detail"),
|
||||
url(r'^domains/(?P<pk>\d+)/dnsbl/$', views.DNSBLDomainDetailView.as_view(),
|
||||
name="dnsbl_domain_detail"),
|
||||
url(r'^domains/(?P<pk>\d+)/mx/$', views.MXDomainDetailView.as_view(),
|
||||
name="mx_domain_detail"),
|
||||
url(r'^domains/list/$', '_domains', name="_domain_list"),
|
||||
url(r'^domains/flatlist/$', 'domains_list', name="domain_flat_list"),
|
||||
url(r'^domains/stats/$', 'domain_statistics', name="domain_statistics"),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from .alias import AliasDetailView
|
||||
from .identity import AccountDetailView
|
||||
from .dnsbl import DNSBLDomainDetailView
|
||||
from .dns import DNSBLDomainDetailView, MXDomainDetailView
|
||||
from .domain import DomainDetailView
|
||||
|
||||
|
||||
@@ -11,4 +11,5 @@ __all__ = [
|
||||
"AliasDetailView",
|
||||
"DNSBLDomainDetailView",
|
||||
"DomainDetailView",
|
||||
"MXDomainDetailView",
|
||||
]
|
||||
|
||||
@@ -9,9 +9,32 @@ from django.contrib.auth import mixins as auth_mixins
|
||||
from .. import models
|
||||
|
||||
|
||||
class MXDomainDetailView(
|
||||
auth_mixins.PermissionRequiredMixin, generic.DetailView):
|
||||
"""View to display MX records."""
|
||||
|
||||
model = models.Domain
|
||||
permission_required = "admin.view_domain"
|
||||
template_name = "admin/mx_domain_detail.html"
|
||||
|
||||
def get_queryset(self):
|
||||
"""Add some prefetching."""
|
||||
return (
|
||||
super(MXDomainDetailView, self).get_queryset()
|
||||
.prefetch_related("mxrecord_set"))
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add extra variables."""
|
||||
context = super(MXDomainDetailView, self).get_context_data(**kwargs)
|
||||
context.update({
|
||||
"title": _("MX records of {}").format(self.object.name)
|
||||
})
|
||||
return context
|
||||
|
||||
|
||||
class DNSBLDomainDetailView(
|
||||
auth_mixins.PermissionRequiredMixin, generic.DetailView):
|
||||
"""DetailView for Domain."""
|
||||
"""View to display DNSBL summary."""
|
||||
|
||||
model = models.Domain
|
||||
permission_required = "admin.view_domain"
|
||||
Reference in New Issue
Block a user