Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
fd35836f
Commit
fd35836f
authored
Mar 24, 2018
by
grisel-davy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finalisation de la page de gestion des droits
parent
40c1d078
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
83 deletions
+72
-83
logs/templates/logs/aff_stats_droits.html
logs/templates/logs/aff_stats_droits.html
+52
-80
logs/views.py
logs/views.py
+20
-3
No files found.
logs/templates/logs/aff_stats_droits.html
View file @
fd35836f
...
...
@@ -25,86 +25,58 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load acl %}
<div
class=
"panel-group"
id=
"accordion"
>
{% for droit in stats_list %}
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading clearfix"
data-parent=
"#accordion"
data-toggle=
"collapse"
data-target=
"#collapse{{droit.id}}"
>
<h2
class=
"panel-title pull-left"
>
<i
class=
"fa fa-address-book"
></i>
{{droit}}
<span
class=
"badge"
>
{{droit.user_set.all.count}}
</span>
</h2>
</div>
<div
class=
"panel-collapse collapse"
id=
"collapse{{droit.id}}"
>
<div
class=
"panel-body"
>
<div
class=
"table-responsive"
>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Pseudo
</th>
<th>
Adhésion
</th>
<th>
Derniere connection
</th>
<th>
Nombre d'actions
</th>
<th>
Supprimer
</th>
</tr>
</thead>
{% for user in droit.user_set.all %}
<tr>
<td>
{{ user.pseudo }}
</td>
{% if user.is_adherent %}
<td><p
class=
"text-success"
>
Adhérent
</p></td>
{% elif not user.end_adhesion %}
<td><p
class=
"text-danger"
>
On ne s'en souvient plus...
</p></td>
{% else %}
<td><p
class=
"text-danger"
>
Plus depuis {{ user.end_adhesion }}
</p></td>
{% endif %}
<td>
{{ user.last_login }}
</td>
<td>
{{ user.name }}
</td>
</tr>
{% endfor %}
</table>
</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>
{% for droit,users in stats_list.items %}
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading clearfix"
data-parent=
"#accordion"
data-toggle=
"collapse"
data-target=
"#collapse{{droit.id}}"
>
<h2
class=
"panel-title pull-left"
>
<i
class=
"fa fa-address-book"
></i>
{{droit}}
<span
class=
"badge"
>
{{users.count}}
</span>
</h2>
</div>
<div
class=
"panel-collapse collapse"
id=
"collapse{{droit.id}}"
>
<div
class=
"panel-body"
>
<div
class=
"table-responsive"
>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Pseudo
</th>
<th>
Adhésion
</th>
<th>
Derniere connexion
</th>
<th>
Nombre d'actions
</th>
<th>
Date de la dernière action
</th>
<th></th>
</tr>
</thead>
{% for utilisateur in users %}
<tr>
<td>
{{ utilisateur.pseudo }}
</td>
{% if utilisateur.is_adherent %}
<td><p
class=
"text-success"
>
Adhérent
</p></td>
{% elif not utilisateur.end_adhesion %}
<td><p
class=
"text-warning"
>
On ne s'en souvient plus...
</p></td>
{% else %}
<td><p
class=
"text-danger"
>
Plus depuis {{ utilisateur.end_adhesion }}
</p></td>
{% endif %}
<td>
{{ utilisateur.last_login }}
</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>
{% endfor %}
</table>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
\ No newline at end of file
logs/views.py
View file @
fd35836f
...
...
@@ -43,10 +43,13 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from
django.contrib
import
messages
from
django.contrib.auth.decorators
import
login_required
from
django.db.models
import
Count
from
django.db.models
import
Max
from
reversion.models
import
Revision
from
reversion.models
import
Version
,
ContentType
from
time
import
time
from
users.models
import
(
User
,
ServiceUser
,
...
...
@@ -450,6 +453,20 @@ def stats_actions(request):
@
login_required
@
can_view_app
(
'users'
)
def
stats_droits
(
request
):
"""Affiche la liste des droits disponibles"""
droits
=
ListRight
.
objects
.
all
().
prefetch_related
(
'user_set'
)
return
render
(
request
,
'logs/stats_droits.html'
,
{
'stats_list'
:
droits
})
"""Affiche la liste des droits et les users ayant chaque droit"""
depart
=
time
()
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
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment