8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 14:42:25 +00:00

Modification du paginateur

Factorisation du machin
This commit is contained in:
Dalahro 2016-10-07 23:40:44 +02:00
parent 331c29a58b
commit 0a847b5a2c
8 changed files with 31 additions and 48 deletions

View file

@ -1,16 +1,5 @@
{% 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>
{% include "pagination.html" with list=facture_list %}
{% endif %}
<table class="table table-striped">

View file

@ -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)

View file

@ -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')

View file

@ -1,16 +1,5 @@
{% 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>
{% include "pagination.html" with list=machines_list %}
{% endif %}
<table class="table table-striped">

View file

@ -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'),
]

View file

@ -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)

17
templates/pagination.html Normal file
View file

@ -0,0 +1,17 @@
<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>

View file

@ -1,16 +1,5 @@
{% 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>
{% include "pagination.html" with list=users_list %}
{% endif %}
<table class="table table-striped">