* Added pagination for admin pages (domains, mailboxes, etc.)

* Code refactoring

see #76
This commit is contained in:
Antoine Nguyen
2011-07-26 14:53:43 +02:00
parent ee6d9554af
commit 81a03d6c65
19 changed files with 381 additions and 226 deletions
+1 -35
View File
@@ -1,4 +1,4 @@
{% extends "admin/domains_header.html" %}
{% extends "admin/listing.html" %}
{% load i18n admin_extras libextras %}
{% block html_head %}
{{ block.super }}
@@ -9,37 +9,3 @@
});
</script>
{% endblock %}
{% block middletitle %}{% trans "Available domains" %}{% endblock %}
{% block subcontent %}
<div id="objects" name="domains" rel="310 190">
{% if not domains %}<div class="info">{% trans "No domain defined." %}</div>
{% else %}
<table id="objects_table">
<tr>
<th>{% trans "Name" %}</th>
<th width="160px">{% trans "Created" %}</th>
<th width="160px">{% trans "Last modified" %}</th>
<th width="100px" class="center">{% trans "Domain aliases" %}</th>
<th width="100px" class="center">{% trans "Mailboxes" %}</th>
<th width="100px" class="center">{% trans "Mailbox aliases" %}</th>
<th width="50px" class="center">{% trans "Quota" %}</th>
<th width="50px" class="center">{% trans "Enabled" %}</th>
<th width="50px" class="center">{% trans "Actions" %}</th>
</tr>
{% for dom in domains %}
<tr class="{% cycle 'odd' 'even' %}" id="{{ dom.id }}">
<td>{{ dom.name }}</td>
<td>{{ dom.dates.creation }}</td>
<td>{{ dom.dates.last_modification }}</td>
<td class="center">{{ dom.domainalias_set.all|length }}</td>
<td class="center">{{ dom.mailbox_set.all|length }}</td>
<td class="center">{{ dom.mbalias_counter }}</td>
<td class="center">{{ dom.quota }} {% trans "MB" %}</td>
<td class="center">{{ dom.enabled|yesno:_("yes,no") }}</td>
<td class="center">{% domain_actions user dom.id %}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
-31
View File
@@ -1,31 +0,0 @@
{% extends "admin/domains_header.html" %}
{% load i18n admin_extras libextras %}
{% block pagetitle %}{% trans "Domain aliases" %}{% endblock %}
{% block subcontent %}
<div id="objects" name="domaliases" rel="310 190">
{% if not domaliases %}
<div class="info">{% trans "No domain alias defined." %}</div>
{% else %}
<table id="objects_table">
<tr>
<th>{% trans "Name" %}</th>
<th>{% trans "Targeted domain" %}</th>
<th width="170px">{% trans "Created" %}</th>
<th width="170px">{% trans "Last modified" %}</th>
<th width="50px" class="center">{% trans "Enabled" %}</th>
<th width="50px" class="center">{% trans "Actions" %}</th>
</tr>
{% for domalias in domaliases %}
<tr class="{% cycle 'odd' 'even' %}" id="{{ domalias.id }}">
<td>{{ domalias.name }}</td>
<td>{{ domalias.target.name }}</td>
<td>{{ domalias.dates.creation }}</td>
<td>{{ domalias.dates.last_modification }}</td>
<td class="center">{{ domalias.enabled|yesno }}</td>
<td class="center">{% domalias_actions user domalias.id %}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
+34
View File
@@ -0,0 +1,34 @@
{% extends "admin/domains_header.html" %}
{% load i18n %}
{% block middletitle %}{{ title }}{% endblock %}
{% block subcontent %}
<div id="objects" name="{{ selection }}" rel="{{ rel }}">
{% if not objects %}<div class="info">{{ emptymsg }}</div>
{% else %}
{{ table }}
{% endif %}
</div>
{% endblock %}
{% block footer %}
<div id="navbar">
{% if total %}
<label>{% trans "Items" %} {{ objects.start_index }} {% trans "to" %} {{ objects.end_index }} {% trans "of" %} {{ total }}</label>
{% endif %}
{% if objects.has_previous %}
<a href="?page=1">
<img src="{{ MEDIA_URL }}pics/first.png" border="0" title="{% trans "First" %}" />
</a>
<a href="?page={{ objects.previous_page_number }}">
<img src="{{ MEDIA_URL }}pics/back.png" border="0" title="{% trans "Previous" %}" />
</a>
{% endif %}
{% if objects.has_next %}
<a href="?page={{ objects.next_page_number }}">
<img src="{{ MEDIA_URL }}pics/next.png" border="0" title="{% trans "Next" %}" />
</a>
<a href="?page={{ page.last_page }}">
<img src="{{ MEDIA_URL }}pics/last.png" border="0" title="{% trans "Last" %}" />
</a>
{% endif %}
</div>
{% endblock %}
-35
View File
@@ -1,35 +0,0 @@
{% extends "admin/domains_header.html" %}
{% load i18n admin_extras %}
{% block pagetitle %}{% trans "Available mailboxes" %}{% endblock %}
{% block subcontent %}
<div id="objects" name="mailboxes" rel="310 320">
{% if not mailboxes %}
<div class="info">{% trans "No mailbox defined." %}</div>
{% else %}
<table id="objects_table">
<tr>
<th>{% trans "Address" %}</th>
<th>{% trans "Name" %}</th>
<th width="160px">{% trans "Created" %}</th>
<th width="160px">{% trans "Last modified" %}</th>
<th width="70px" class="center">{% trans "Aliases" %}</th>
<th width="50px" class="center">{% trans "Quota" %}</th>
<th width="50px" class="center">{{ "Enabled"|gender:"f" }}</th>
<th width="70px" class="center">{% trans "Actions" %}</th>
</tr>
{% for mb in mailboxes %}
<tr class="{% cycle 'odd' 'even' %}" id="{{ mb.id }}">
<td>{{ mb.full_address }}</td>
<td>{{ mb.name }}</td>
<td>{{ mb.dates.creation }}</td>
<td>{{ mb.dates.last_modification }}</td>
<td class="center">{{ mb.alias_set.all|length }}</td>
<td class="center">{{ mb.quota }} {% trans "MB" %}</td>
<td class="center">{{ mb.user.is_active|yesno:_("yes,no") }}</td>
<td class="center">{% mailbox_actions user mb %}</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
-39
View File
@@ -1,39 +0,0 @@
{% extends "admin/domains_header.html" %}
{% load i18n admin_extras %}
{% block pagetitle %}{% trans "Mailbox aliases" %}{% endblock %}
{% block subcontent %}
<div id="objects" name="mbaliases" rel="320 300">
{% if not aliases %}
<div class="info">{% trans "No mailbox alias defined." %}</div>
{% else %}
<table id="objects_table">
<tr>
<th>{% trans "Address" %}</th>
<th>{% trans "Target(s)" %}</th>
<th width="170px">{% trans "Created" %}</th>
<th width="170px">{% trans "Last modified" %}</th>
<th width="50px" class="center">{% trans "Enabled" %}</th>
<th width="50px" class="center">{% trans "Actions" %}</th>
</tr>
{% for alias in aliases %}
<tr class="{% cycle 'odd' 'even' %}" id="{{ alias.id }}"
rel="{ui_disabled : '{{ alias.ui_disabled }}'}">
<td>{{ alias.address }}@{{ alias.domain }}</td>
<td>
{% for mb in alias.mboxes.all %}
{{ mb.full_address }}<br/>
{% endfor %}
{{ alias.repr_extmboxes|safe }}
</td>
<td>{{ alias.dates.creation }}</td>
<td>{{ alias.dates.last_modification }}</td>
<td class="center">{{ alias.enabled|yesno }}</td>
<td class="center">
{% if alias.ui_disabled %}--{% else %}{% mbalias_actions user alias %}{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
{% endblock %}
-20
View File
@@ -7,26 +7,6 @@
<script type="text/javascript" src="{{ MEDIA_URL }}js/ProgressBar.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/email_listing.js"></script>
{% block css %}{% endblock %}
<style type="text/css">
#navbar {
float: right;
padding: 0;
margin: 0;
text-align: right;
}
#navbar label {
color: white;
margin-right: 5px;
font-weight: bold;
}
#navbar img{
margin-top: 5px;
margin-right: 5px;
}
</style>
<script type="text/javascript">
var current_anchor = new AnchorNavigation("{{ deflocation }}");
+2 -1
View File
@@ -1,6 +1,7 @@
<tbody>
{% for row in table.rows %}
<tr id="{{ row.id }}" class="{% cycle 'odd' 'even' %}" name="{{ row.trcpt }}">
<tr id="{{ row.id }}" class="{% cycle 'odd' 'even' %}" name="{{ row.trcpt }}"
rel="{{ row.options }}">
{% for cell in row.cols %}
<td name="{{ cell.name }}" width="{{ cell.width }}" align="{{ cell.align }}" class="{{ cell.cssclass }}">
{% if cell.safe %}{{ cell.value|safe }}{% else %}{{ cell.value }}{% endif %}