mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +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,17 +1,6 @@
|
|||
{% 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')
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
{% 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)
|
||||
|
||||
|
|
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,17 +1,6 @@
|
|||
{% 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>
|
||||
|
|
Loading…
Reference in a new issue