Commit 4bb831f1 authored by Dalahro's avatar Dalahro

Modification du paginateur

Factorisation du machin
parent b1aecb6f
{% if facture_list.paginator %}
<ul class="pagination nav navbar-nav">
{% if facture_list.has_previous %}
<li><a href="?page={{ facture_list.previous_page_number }}">Suivantes</a></li>
{% endif %}
{% for page in facture_list.paginator.page_range %}
<li class="{% if facture_list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
{% endfor %}
{% if facture_list.has_next %}
<li> <a href="?page={{ facture_list.next_page_number }}">Précédentes</a></li>
{% endif %}
</ul>
{% endif %}
{% if facture_list.paginator %}
{% include "pagination.html" with list=facture_list %}
{% endif %}
<table class="table table-striped">
<thead>
......
......@@ -66,4 +66,4 @@ def interface_post_save(sender, **kwargs):
@receiver(post_delete, sender=Interface)
def interface_post_delete(sender, **kwargs):
user = kwargs['instance'].machine.user
user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
#user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
......@@ -4,7 +4,7 @@ from machines.models import Interface
class InterfaceSerializer( serializers.ModelSerializer):
class Meta:
model = Interface
fields = ('ipv4', 'mac_address', 'dns')
fields = ('ipv4', 'mac_address', 'dns', 'type')
{% if machines_list.paginator %}
<ul class="pagination nav navbar-nav">
{% if machines_list.has_previous %}
<li><a href="?page={{ machines_list.previous_page_number }}">Suivants</a></li>
{% endif %}
{% for page in machines_list.paginator.page_range %}
<li class="{% if machines_list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
{% endfor %}
{% if machines_list.has_next %}
<li> <a href="?page={{ machines_list.next_page_number }}">Précédents</a></li>
{% endif %}
</ul>
{% endif %}
{% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %}
{% endif %}
<table class="table table-striped">
<thead>
......
......@@ -22,5 +22,5 @@ urlpatterns = [
url(r'^history/(?P<object>extension)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^$', views.index, name='index'),
url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'),
url(r'^rest/dns-ip/$', views.dns_ip, name='dns-ip'),
url(r'^rest/mac-ip-dns/$', views.mac_ip_dns, name='mac-ip-dns'),
]
......@@ -415,8 +415,7 @@ def mac_ip(request):
s.pop('dns')
return JSONResponse(seria)
def dns_ip(request):
def mac_ip_dns(request):
seria = interface_list(request)
for s in seria:
s.pop('mac_address')
return JSONResponse(seria)
<ul class="pagination nav navbar-nav">
{% if list.has_previous %}
<li><a href="?page=1"> << </a></li>
<li><a href="?page={{ list.previous_page_number }}"> < </a></li>
{% endif %}
{% for page in list.paginator.page_range %}
{% if list.number <= page|add:"3" and list.number >= page|add:"-3" %}
<li class="{% if list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
{% endif %}
{% endfor %}
{% if list.has_next %}
<li><a href="?page={{ list.next_page_number }}"> > </a></li>
<li><a href="?page={{ list.paginator.page_range|length }}"> >> </a></li>
{% endif %}
</ul>
{% if users_list.paginator %}
<ul class="pagination nav navbar-nav">
{% if users_list.has_previous %}
<li><a href="?page={{ users_list.previous_page_number }}">Suivants</a></li>
{% endif %}
{% for page in users_list.paginator.page_range %}
<li class="{% if users_list.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
{% endfor %}
{% if users_list.has_next %}
<li> <a href="?page={{ users_list.next_page_number }}">Précédents</a></li>
{% endif %}
</ul>
{% endif %}
{% if users_list.paginator %}
{% include "pagination.html" with list=users_list %}
{% endif %}
<table class="table table-striped">
<thead>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment