mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 00:43:46 +00:00
FIx paginateur sur les whitelist
This commit is contained in:
parent
450819e4b9
commit
fbd685747b
4 changed files with 32 additions and 2 deletions
|
@ -668,6 +668,9 @@ class Ban(models.Model):
|
||||||
general_options.email_from, [self.user.email], fail_silently=False)
|
general_options.email_from, [self.user.email], fail_silently=False)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def is_active(self):
|
||||||
|
return self.date_end > now
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.user) + ' ' + str(self.raison)
|
return str(self.user) + ' ' + str(self.raison)
|
||||||
|
|
||||||
|
@ -702,6 +705,9 @@ class Whitelist(models.Model):
|
||||||
date_start = models.DateTimeField(auto_now_add=True)
|
date_start = models.DateTimeField(auto_now_add=True)
|
||||||
date_end = models.DateTimeField(help_text='%d/%m/%y %H:%M:%S')
|
date_end = models.DateTimeField(help_text='%d/%m/%y %H:%M:%S')
|
||||||
|
|
||||||
|
def is_active(self):
|
||||||
|
return self.date_end > now
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.user) + ' ' + str(self.raison)
|
return str(self.user) + ' ' + str(self.raison)
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for ban in ban_list %}
|
{% for ban in ban_list %}
|
||||||
<tr>
|
{% if ban.is_active %}
|
||||||
|
<tr class="bg-danger text-white">
|
||||||
|
{% else %}
|
||||||
|
<tr class="bg-warning text-white">
|
||||||
|
{% endif %}
|
||||||
<td>{{ ban.user }}</td>
|
<td>{{ ban.user }}</td>
|
||||||
<td>{{ ban.raison }}</td>
|
<td>{{ ban.raison }}</td>
|
||||||
<td>{{ ban.date_start }}</td>
|
<td>{{ ban.date_start }}</td>
|
||||||
|
|
|
@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% if white_list.paginator %}
|
||||||
|
{% include "pagination.html" with list=white_list %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -33,7 +37,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for whitelist in white_list %}
|
{% for whitelist in white_list %}
|
||||||
<tr>
|
{% if whitelist.is_active %}
|
||||||
|
<tr class="bg-success text-white">
|
||||||
|
{% else %}
|
||||||
|
<tr class="bg-warning text-white">
|
||||||
|
{% endif %}
|
||||||
<td>{{ whitelist.user }}</td>
|
<td>{{ whitelist.user }}</td>
|
||||||
<td>{{ whitelist.raison }}</td>
|
<td>{{ whitelist.raison }}</td>
|
||||||
<td>{{ whitelist.date_start }}</td>
|
<td>{{ whitelist.date_start }}</td>
|
||||||
|
|
|
@ -527,7 +527,19 @@ def index_ban(request):
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index_white(request):
|
def index_white(request):
|
||||||
""" Affiche l'ensemble des whitelist, need droit cableur """
|
""" Affiche l'ensemble des whitelist, need droit cableur """
|
||||||
|
options, created = GeneralOption.objects.get_or_create()
|
||||||
|
pagination_number = options.pagination_number
|
||||||
white_list = Whitelist.objects.select_related('user').order_by('date_start')
|
white_list = Whitelist.objects.select_related('user').order_by('date_start')
|
||||||
|
paginator = Paginator(white_list, pagination_number)
|
||||||
|
page = request.GET.get('page')
|
||||||
|
try:
|
||||||
|
white_list = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
# If page isn't an integer, deliver first page
|
||||||
|
white_list = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||||
|
white_list = paginator.page(paginator.num_pages)
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
'users/index_whitelist.html',
|
'users/index_whitelist.html',
|
||||||
|
|
Loading…
Reference in a new issue