mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 19:33:11 +00:00
finalisation de la page de gestion des droits
This commit is contained in:
parent
40c1d078a4
commit
fd35836f47
2 changed files with 73 additions and 84 deletions
|
@ -25,86 +25,58 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load acl %}
|
{% load acl %}
|
||||||
|
|
||||||
<div class="panel-group" id="accordion">
|
{% for droit,users in stats_list.items %}
|
||||||
{% for droit in stats_list %}
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading clearfix" data-parent="#accordion" data-toggle="collapse" data-target="#collapse{{droit.id}}">
|
<div class="panel-heading clearfix" data-parent="#accordion" data-toggle="collapse" data-target="#collapse{{droit.id}}">
|
||||||
<h2 class="panel-title pull-left">
|
<h2 class="panel-title pull-left">
|
||||||
<i class="fa fa-address-book"></i>
|
<i class="fa fa-address-book"></i>
|
||||||
{{droit}}
|
{{droit}}
|
||||||
<span class="badge">{{droit.user_set.all.count}}</span>
|
<span class="badge">{{users.count}}</span>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-collapse collapse" id="collapse{{droit.id}}">
|
<div class="panel-collapse collapse" id="collapse{{droit.id}}">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Pseudo</th>
|
<th>Pseudo</th>
|
||||||
<th>Adhésion</th>
|
<th>Adhésion</th>
|
||||||
<th>Derniere connection</th>
|
<th>Derniere connexion</th>
|
||||||
<th>Nombre d'actions</th>
|
<th>Nombre d'actions</th>
|
||||||
<th>Supprimer </th>
|
<th>Date de la dernière action</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for user in droit.user_set.all %}
|
{% for utilisateur in users %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.pseudo }}</td>
|
<td>{{ utilisateur.pseudo }}</td>
|
||||||
{% if user.is_adherent %}
|
{% if utilisateur.is_adherent %}
|
||||||
<td><p class="text-success">Adhérent</p></td>
|
<td><p class="text-success">Adhérent</p></td>
|
||||||
{% elif not user.end_adhesion %}
|
{% elif not utilisateur.end_adhesion %}
|
||||||
<td><p class="text-danger">On ne s'en souvient plus...</p></td>
|
<td><p class="text-warning">On ne s'en souvient plus...</p></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><p class="text-danger">Plus depuis {{ user.end_adhesion }}</p></td>
|
<td><p class="text-danger">Plus depuis {{ utilisateur.end_adhesion }}</p></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>{{ user.last_login }}</td>
|
<td>{{ utilisateur.last_login }}</td>
|
||||||
<td>{{ user.name }}</td>
|
<td>{{ utilisateur.num }}</td>
|
||||||
|
{% if not utilisateur.last %}
|
||||||
|
<td><p class="text-danger">Jamais</p></td>
|
||||||
|
{% else %}
|
||||||
|
<td><p class="text-success">{{utilisateur.last}}</p></td>
|
||||||
|
{% endif %}
|
||||||
|
<td>
|
||||||
|
<a href="{% url 'users:del-group' utilisateur.id droit.id %}">
|
||||||
|
<button type="button" class="btn btn-danger" aria-label="Left Align">
|
||||||
|
<span class="fa fa-user-times" aria-hidden="true"></span>
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<div class="table-responsive" ">
|
|
||||||
<table class="table table-striped" ">
|
|
||||||
|
|
||||||
{% for user in droit.user_set.all %}
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<div class="table-responsive" ">
|
|
||||||
<table class="table table-striped" ">
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>Pseudo</td>
|
|
||||||
<td>Adhésion</td>
|
|
||||||
<td>Derniere connection</td>
|
|
||||||
<td>Nombre d'actions</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>{{ user.name }}</td>
|
|
||||||
<td>{{ user.is_adherent }}</td>
|
|
||||||
<td>{{ user.last_login }}</td>
|
|
||||||
<td>{{ user.name }}</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
|
||||||
|
|
|
@ -43,10 +43,13 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
|
from django.db.models import Max
|
||||||
|
|
||||||
from reversion.models import Revision
|
from reversion.models import Revision
|
||||||
from reversion.models import Version, ContentType
|
from reversion.models import Version, ContentType
|
||||||
|
|
||||||
|
from time import time
|
||||||
|
|
||||||
from users.models import (
|
from users.models import (
|
||||||
User,
|
User,
|
||||||
ServiceUser,
|
ServiceUser,
|
||||||
|
@ -450,6 +453,20 @@ def stats_actions(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_view_app('users')
|
@can_view_app('users')
|
||||||
def stats_droits(request):
|
def stats_droits(request):
|
||||||
"""Affiche la liste des droits disponibles"""
|
"""Affiche la liste des droits et les users ayant chaque droit"""
|
||||||
droits=ListRight.objects.all().prefetch_related('user_set')
|
depart=time()
|
||||||
return render(request, 'logs/stats_droits.html', {'stats_list': droits})
|
stats_list={}
|
||||||
|
|
||||||
|
for droit in ListRight.objects.all().select_related('group_ptr'):#.prefetch_related('group_ptr__user_set__revision_set'):
|
||||||
|
stats_list[droit]=droit.user_set.all().annotate(num=Count('revision'),last=Max('revision__date_created'))
|
||||||
|
|
||||||
|
# count,last=0,0
|
||||||
|
# for droit in ListRight.objects.all():
|
||||||
|
# for use in droit.user_set.all():
|
||||||
|
# countRevision.objects.filter(user=use).count()
|
||||||
|
# print(Revision.objects.order_by('date_created').last().date_created)
|
||||||
|
# stats_list[droit]=use.annotate(num=count,las)
|
||||||
|
|
||||||
|
#raise ValueError('temps='+str(time()-depart))
|
||||||
|
|
||||||
|
return render(request, 'logs/stats_droits.html', {'stats_list': stats_list})
|
||||||
|
|
Loading…
Reference in a new issue