diff --git a/cotisations/templates/cotisations/aff_cotisations.html b/cotisations/templates/cotisations/aff_cotisations.html
index 18ed3865..dfee06e8 100644
--- a/cotisations/templates/cotisations/aff_cotisations.html
+++ b/cotisations/templates/cotisations/aff_cotisations.html
@@ -1,3 +1,18 @@
+ {% if facture_list.paginator %}
+
+ {% endif %}
+
diff --git a/cotisations/views.py b/cotisations/views.py
index 55bed964..29162353 100644
--- a/cotisations/views.py
+++ b/cotisations/views.py
@@ -4,6 +4,7 @@
from django.shortcuts import render, redirect
from django.shortcuts import render_to_response, get_object_or_404
from django.core.context_processors import csrf
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.template import Context, RequestContext, loader
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib import messages
@@ -17,7 +18,7 @@ from .models import Facture, Article, Vente, Cotisation, Paiement, Banque
from .forms import NewFactureForm, TrezEditFactureForm, EditFactureForm, ArticleForm, DelArticleForm, PaiementForm, DelPaiementForm, BanqueForm, DelBanqueForm, NewFactureFormPdf, SelectArticleForm
from users.models import User
from .tex import render_tex
-from re2o.settings import ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH
+from re2o.settings import ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, PAGINATION_NUMBER
from re2o import settings
from dateutil.relativedelta import relativedelta
@@ -341,6 +342,16 @@ def index_banque(request):
@permission_required('cableur')
def index(request):
facture_list = Facture.objects.order_by('date').reverse()
+ paginator = Paginator(facture_list, PAGINATION_NUMBER)
+ page = request.GET.get('page')
+ try:
+ facture_list = paginator.page(page)
+ except PageNotAnInteger:
+ # If page is not an integer, deliver first page.
+ facture_list = paginator.page(1)
+ except EmptyPage:
+ # If page is out of range (e.g. 9999), deliver last page of results.
+ facture_list = paginator.page(paginator.num_pages)
return render(request, 'cotisations/index.html', {'facture_list': facture_list})
@login_required
diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html
index ccb27844..54be85e8 100644
--- a/machines/templates/machines/aff_machines.html
+++ b/machines/templates/machines/aff_machines.html
@@ -1,3 +1,18 @@
+ {% if machines_list.paginator %}
+
+ {% endif %}
+
diff --git a/machines/views.py b/machines/views.py
index 327e2483..b77250b1 100644
--- a/machines/views.py
+++ b/machines/views.py
@@ -5,6 +5,7 @@ from django.http import HttpResponse
from django.shortcuts import render, redirect
from django.shortcuts import render_to_response, get_object_or_404
from django.core.context_processors import csrf
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.template import Context, RequestContext, loader
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
@@ -21,6 +22,7 @@ import re
from .forms import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, MachineTypeForm, DelMachineTypeForm, ExtensionForm, DelExtensionForm, BaseEditInterfaceForm, BaseEditMachineForm
from .models import Machine, Interface, IpList, MachineType, Extension
from users.models import User
+from re2o.settings import PAGINATION_NUMBER
def full_domain_validator(request, interface):
""" Validation du nom de domaine, extensions dans type de machine, prefixe pas plus long que 63 caractères """
@@ -313,6 +315,16 @@ def del_extension(request):
@permission_required('cableur')
def index(request):
machines_list = Machine.objects.order_by('pk')
+ paginator = Paginator(machines_list, PAGINATION_NUMBER)
+ page = request.GET.get('page')
+ try:
+ machines_list = paginator.page(page)
+ except PageNotAnInteger:
+ # If page is not an integer, deliver first page.
+ machines_list = paginator.page(1)
+ except EmptyPage:
+ # If page is out of range (e.g. 9999), deliver last page of results.
+ machines_list = paginator.page(paginator.num_pages)
return render(request, 'machines/index.html', {'machines_list': machines_list})
@login_required
diff --git a/re2o/settings.py b/re2o/settings.py
index cd6a9e27..e6391e53 100644
--- a/re2o/settings.py
+++ b/re2o/settings.py
@@ -131,3 +131,4 @@ RIGHTS_LINK = {
'bofh' : ['bureau','trésorier'],
}
+PAGINATION_NUMBER = 5
diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html
index fb49a8b8..c86efaf5 100644
--- a/users/templates/users/aff_users.html
+++ b/users/templates/users/aff_users.html
@@ -1,3 +1,18 @@
+ {% if users_list.paginator %}
+
+ {% endif %}
+
diff --git a/users/views.py b/users/views.py
index 66322fb5..0c6fe6cb 100644
--- a/users/views.py
+++ b/users/views.py
@@ -3,6 +3,7 @@
# Gplv2
from django.shortcuts import render_to_response, get_object_or_404, render, redirect
from django.core.context_processors import csrf
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.template import Context, RequestContext, loader
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
@@ -14,7 +15,7 @@ from django.core.urlresolvers import reverse
from django.db import transaction
from reversion import revisions as reversion
-from users.models import User, Right, Ban, Whitelist, School, Request
+from users.models import User, Right, Ban, Whitelist, School, ListRight, Request
from users.models import DelRightForm, BanForm, WhitelistForm, DelSchoolForm
from users.models import InfoForm, BaseInfoForm, StateForm, RightForm, SchoolForm
from cotisations.models import Facture
@@ -23,7 +24,7 @@ from users.forms import PassForm, ResetPasswordForm
from machines.views import unassign_ips, assign_ips
from re2o.login import hashNT
-from re2o.settings import REQ_EXPIRE_STR, EMAIL_FROM, ASSO_NAME, ASSO_EMAIL, SITE_NAME
+from re2o.settings import REQ_EXPIRE_STR, EMAIL_FROM, ASSO_NAME, ASSO_EMAIL, SITE_NAME, PAGINATION_NUMBER
def archive(user):
""" Archive un utilisateur """
@@ -182,13 +183,14 @@ def add_right(request, userid):
@login_required
@permission_required('bureau')
def del_right(request):
- right = DelRightForm(request.POST or None)
- if right.is_valid():
- right_del = right.cleaned_data['rights']
+ user_right_list = DelRightForm(request.POST or None)
+ right_list = ListRight.objects.all()
+ if user_right_list.is_valid():
+ right_del = user_right_list.cleaned_data['rights']
right_del.delete()
messages.success(request, "Droit retiré avec succès")
return redirect("/users/")
- return form({'userform': right}, 'users/user.html', request)
+ return form({'user_right_list': user_right_list, 'right_list': right_list}, 'users/index_rights.html', request)
@login_required
@permission_required('bofh')
@@ -329,6 +331,16 @@ def del_school(request):
@permission_required('cableur')
def index(request):
users_list = User.objects.order_by('pk')
+ paginator = Paginator(users_list, PAGINATION_NUMBER)
+ page = request.GET.get('page')
+ try:
+ users_list = paginator.page(page)
+ except PageNotAnInteger:
+ # If page is not an integer, deliver first page.
+ users_list = paginator.page(1)
+ except EmptyPage:
+ # If page is out of range (e.g. 9999), deliver last page of results.
+ users_list = paginator.page(paginator.num_pages)
return render(request, 'users/index.html', {'users_list': users_list})
@login_required