mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Modification du paginateur
Factorisation du machin
This commit is contained in:
parent
b1aecb6ff5
commit
4bb831f18d
8 changed files with 31 additions and 48 deletions
|
@ -1,16 +1,5 @@
|
||||||
{% if facture_list.paginator %}
|
{% if facture_list.paginator %}
|
||||||
<ul class="pagination nav navbar-nav">
|
{% include "pagination.html" with list=facture_list %}
|
||||||
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
|
|
@ -66,4 +66,4 @@ def interface_post_save(sender, **kwargs):
|
||||||
@receiver(post_delete, sender=Interface)
|
@receiver(post_delete, sender=Interface)
|
||||||
def interface_post_delete(sender, **kwargs):
|
def interface_post_delete(sender, **kwargs):
|
||||||
user = kwargs['instance'].machine.user
|
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 InterfaceSerializer( serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ('ipv4', 'mac_address', 'dns')
|
fields = ('ipv4', 'mac_address', 'dns', 'type')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
{% if machines_list.paginator %}
|
{% if machines_list.paginator %}
|
||||||
<ul class="pagination nav navbar-nav">
|
{% include "pagination.html" with list=machines_list %}
|
||||||
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
|
|
@ -22,5 +22,5 @@ urlpatterns = [
|
||||||
url(r'^history/(?P<object>extension)/(?P<id>[0-9]+)$', views.history, name='history'),
|
url(r'^history/(?P<object>extension)/(?P<id>[0-9]+)$', views.history, name='history'),
|
||||||
url(r'^$', views.index, name='index'),
|
url(r'^$', views.index, name='index'),
|
||||||
url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'),
|
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')
|
s.pop('dns')
|
||||||
return JSONResponse(seria)
|
return JSONResponse(seria)
|
||||||
|
|
||||||
def dns_ip(request):
|
def mac_ip_dns(request):
|
||||||
seria = interface_list(request)
|
seria = interface_list(request)
|
||||||
for s in seria:
|
|
||||||
s.pop('mac_address')
|
|
||||||
return JSONResponse(seria)
|
return JSONResponse(seria)
|
||||||
|
|
||||||
|
|
17
templates/pagination.html
Normal file
17
templates/pagination.html
Normal 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>
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
{% if users_list.paginator %}
|
{% if users_list.paginator %}
|
||||||
<ul class="pagination nav navbar-nav">
|
{% include "pagination.html" with list=users_list %}
|
||||||
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
|
Loading…
Reference in a new issue