mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 20:03:11 +00:00
Merge branch 'tableau_de_bord'
This commit is contained in:
commit
cbd6fe00a2
1 changed files with 27 additions and 18 deletions
|
@ -79,30 +79,39 @@ def index(request):
|
||||||
# Select only wanted versions
|
# Select only wanted versions
|
||||||
versions = Version.objects.filter(content_type__in=ContentType.objects.filter(model__in=content_type_filter)).order_by('revision__date_created').reverse().select_related('revision')
|
versions = Version.objects.filter(content_type__in=ContentType.objects.filter(model__in=content_type_filter)).order_by('revision__date_created').reverse().select_related('revision')
|
||||||
|
|
||||||
# Setup nice struct for template
|
paginator = Paginator(versions, pagination_number)
|
||||||
versions_list = []
|
|
||||||
for v in versions :
|
|
||||||
if v.object :
|
|
||||||
versions_list.append(
|
|
||||||
{'rev_id' : v.revision.id,
|
|
||||||
'comment': v.revision.comment,
|
|
||||||
'datetime': v.revision.date_created.strftime('%d/%m/%y %H:%M:%S'),
|
|
||||||
'username': v.revision.user.get_username() if v.revision.user else '?',
|
|
||||||
'user_id': v.revision.user_id,
|
|
||||||
'version': v }
|
|
||||||
)
|
|
||||||
|
|
||||||
paginator = Paginator(versions_list, pagination_number)
|
|
||||||
page = request.GET.get('page')
|
page = request.GET.get('page')
|
||||||
try:
|
try:
|
||||||
versions_list = paginator.page(page)
|
versions = paginator.page(page)
|
||||||
except PageNotAnInteger:
|
except PageNotAnInteger:
|
||||||
# If page is not an integer, deliver first page.
|
# If page is not an integer, deliver first page.
|
||||||
versions_list = paginator.page(1)
|
versions = paginator.page(1)
|
||||||
except EmptyPage:
|
except EmptyPage:
|
||||||
# If page is out of range (e.g. 9999), deliver last page of results.
|
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||||
versions_list = paginator.page(paginator.num_pages)
|
versions = paginator.page(paginator.num_pages)
|
||||||
return render(request, 'logs/index.html', {'versions_list': versions_list})
|
|
||||||
|
# Force to have a list instead of QuerySet
|
||||||
|
versions.count(0)
|
||||||
|
# Items to remove later because invalid
|
||||||
|
to_remove = []
|
||||||
|
# Parse every item (max = pagination_number)
|
||||||
|
for i in range( len( versions.object_list ) ):
|
||||||
|
if versions.object_list[i].object :
|
||||||
|
v = versions.object_list[i]
|
||||||
|
versions.object_list[i] = {
|
||||||
|
'rev_id' : v.revision.id,
|
||||||
|
'comment': v.revision.comment,
|
||||||
|
'datetime': v.revision.date_created.strftime('%d/%m/%y %H:%M:%S'),
|
||||||
|
'username': v.revision.user.get_username() if v.revision.user else '?',
|
||||||
|
'user_id': v.revision.user_id,
|
||||||
|
'version': v }
|
||||||
|
else :
|
||||||
|
to_remove.append(i)
|
||||||
|
# Remove all tagged invalid items
|
||||||
|
for i in to_remove :
|
||||||
|
versions.object_list.pop(i)
|
||||||
|
|
||||||
|
return render(request, 'logs/index.html', {'versions_list': versions})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
|
|
Loading…
Reference in a new issue