mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 14:42:25 +00:00
Merge branch 'tableau_de_bord' into 'master'
Tableau de bord See merge request !9
This commit is contained in:
commit
cf956dcf08
7 changed files with 228 additions and 3 deletions
147
logs/templates/logs/aff_summary.html
Normal file
147
logs/templates/logs/aff_summary.html
Normal file
|
@ -0,0 +1,147 @@
|
|||
{% comment %}
|
||||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||
se veut agnostique au réseau considéré, de manière à être installable en
|
||||
quelques clics.
|
||||
|
||||
Copyright © 2017 Gabriel Détraz
|
||||
Copyright © 2017 Goulven Kermarec
|
||||
Copyright © 2017 Augustin Lemesle
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% if versions_list.paginator %}
|
||||
{% include "pagination.html" with list=versions_list %}
|
||||
{% endif %}
|
||||
|
||||
{% load logs_extra %}
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Modification</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for v in versions_list %}
|
||||
{% if v.version.content_type.model == 'ban' %}
|
||||
<tr class="danger">
|
||||
<td>{{ v.datetime }}</td>
|
||||
<td>
|
||||
{{ v.username }} a banni
|
||||
<a href="{% url 'users:profil' v.version.object.user_id %}">{{ v.version.object.user.get_username }}</a>
|
||||
(<i>
|
||||
{% if v.version.object.raison == '' %}
|
||||
Aucune raison
|
||||
{% else %}
|
||||
{{ v.version.object.raison }}
|
||||
{% endif %}
|
||||
</i>)
|
||||
</td>
|
||||
{% if is_bureau %}
|
||||
<td>
|
||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' v.rev_id %}">
|
||||
<i class="glyphicon glyphicon-remove"></i>
|
||||
Annuler
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% elif v.version.content_type.model == 'whitelist' %}
|
||||
<tr class="success">
|
||||
<td>{{ v.datetime }}</td>
|
||||
<td>
|
||||
{{ v.username }} a autorisé gracieusement
|
||||
<a href="{% url 'users:profil' v.version.object.user_id %}">{{ v.version.object.user.get_username }}</a>
|
||||
(<i>
|
||||
{% if v.version.object.raison == '' %}
|
||||
Aucune raison
|
||||
{% else %}
|
||||
{{ v.version.object.raison }}
|
||||
{% endif %}
|
||||
</i>)
|
||||
</td>
|
||||
{% if is_bureau %}
|
||||
<td>
|
||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' v.rev_id %}">
|
||||
<i class="glyphicon glyphicon-remove"></i>
|
||||
Annuler
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% elif v.version.content_type.model == 'user' %}
|
||||
<tr>
|
||||
<td>{{ v.datetime }}</td>
|
||||
<td>
|
||||
{{ v.username }} a mis à jour
|
||||
<a href="{% url 'users:profil' v.version.object.id %}">{{ v.version.object.get_username }}</a>
|
||||
{% if v.comment != '' %}
|
||||
(<i>{{ v.comment }}</i>)
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if is_bureau %}
|
||||
<td>
|
||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' v.rev_id %}">
|
||||
<i class="glyphicon glyphicon-remove"></i>
|
||||
Annuler
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% elif v.version.content_type.model == 'vente' %}
|
||||
<tr>
|
||||
<td>{{ v.datetime }}</td>
|
||||
<td>
|
||||
{{ v.username }} a vendu {{ v.version.object.number }}x {{ v.version.object.name }} à
|
||||
<a href="{% url 'users:profil' v.version.object.facture.user_id %}">{{ v.version.object.facture.user.get_username }}</a>
|
||||
{% if v.version.object.iscotisation %}
|
||||
(<i>+{{ v.version.object.duration }} mois</i>)
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if is_bureau %}
|
||||
<td>
|
||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' v.rev_id %}">
|
||||
<i class="glyphicon glyphicon-remove"></i>
|
||||
Annuler
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% elif v.version.content_type.model == 'interface' %}
|
||||
<tr>
|
||||
<td>{{ v.datetime }}</td>
|
||||
<td>
|
||||
{{ v.username }} a modifié une interface de
|
||||
<a href="{% url 'users:profil' v.version.object.machine.user_id %}">{{ v.version.object.machine.user.get_username }}</a>
|
||||
{% if v.comment != '' %}
|
||||
(<i>{{ v.comment }}</i>)
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if is_bureau %}
|
||||
<td>
|
||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' v.rev_id %}">
|
||||
<i class="glyphicon glyphicon-remove"></i>
|
||||
Annuler
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
{% block content %}
|
||||
<h2>Actions effectuées</h2>
|
||||
{% include "logs/aff_actions.html" with revisions_list=revisions_list %}
|
||||
{% include "logs/aff_summary.html" with versions_list=versions_list %}
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -27,6 +27,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% block sidebar %}
|
||||
{% if is_cableur %}
|
||||
<a class="list-group-item list-group-item-info" href="{% url "logs:index" %}">
|
||||
<i class="glyphicon glyphicon-stats"></i>
|
||||
Résumé
|
||||
</a>
|
||||
<a class="list-group-item list-group-item-info" href="{% url "logs:stats-logs" %}">
|
||||
<i class="glyphicon glyphicon-stats"></i>
|
||||
Évènements
|
||||
</a>
|
||||
|
|
36
logs/templates/logs/stats_logs.html
Normal file
36
logs/templates/logs/stats_logs.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
{% extends "logs/sidebar.html" %}
|
||||
{% comment %}
|
||||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||
se veut agnostique au réseau considéré, de manière à être installable en
|
||||
quelques clics.
|
||||
|
||||
Copyright © 2017 Gabriel Détraz
|
||||
Copyright © 2017 Goulven Kermarec
|
||||
Copyright © 2017 Augustin Lemesle
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
|
||||
{% block title %}Statistiques{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Actions effectuées</h2>
|
||||
{% include "logs/aff_stats_logs.html" with revisions_list=revisions_list %}
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
{% endblock %}
|
|
@ -28,6 +28,7 @@ from . import views
|
|||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name='index'),
|
||||
url(r'^stats_logs$', views.stats_logs, name='stats-logs'),
|
||||
url(r'^revert_action/(?P<revision_id>[0-9]+)$', views.revert_action, name='revert-action'),
|
||||
url(r'^stats_general/$', views.stats_general, name='stats-general'),
|
||||
url(r'^stats_models/$', views.stats_models, name='stats-models'),
|
||||
|
|
|
@ -40,7 +40,7 @@ from django.db import transaction
|
|||
from django.db.models import Count
|
||||
|
||||
from reversion.models import Revision
|
||||
from reversion.models import Version
|
||||
from reversion.models import Version, ContentType
|
||||
|
||||
from users.models import User, ServiceUser, Right, School, ListRight, ListShell, Ban, Whitelist
|
||||
from users.models import all_has_access, all_whitelisted, all_baned, all_adherent
|
||||
|
@ -72,6 +72,43 @@ def form(ctx, template, request):
|
|||
def index(request):
|
||||
options, created = GeneralOption.objects.get_or_create()
|
||||
pagination_number = options.pagination_number
|
||||
|
||||
# The types of content kept for display
|
||||
content_type_filter = ['ban', 'whitelist', 'vente', 'interface', 'user']
|
||||
|
||||
# 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')
|
||||
|
||||
# Setup nice struct for template
|
||||
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')
|
||||
try:
|
||||
versions_list = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
# If page is not an integer, deliver first page.
|
||||
versions_list = paginator.page(1)
|
||||
except EmptyPage:
|
||||
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||
versions_list = paginator.page(paginator.num_pages)
|
||||
return render(request, 'logs/index.html', {'versions_list': versions_list})
|
||||
|
||||
@login_required
|
||||
@permission_required('cableur')
|
||||
def stats_logs(request):
|
||||
options, created = GeneralOption.objects.get_or_create()
|
||||
pagination_number = options.pagination_number
|
||||
revisions = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related('version_set__object')
|
||||
paginator = Paginator(revisions, pagination_number)
|
||||
page = request.GET.get('page')
|
||||
|
@ -83,7 +120,7 @@ def index(request):
|
|||
except EmptyPage:
|
||||
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||
revisions = paginator.page(paginator.num_pages)
|
||||
return render(request, 'logs/index.html', {'revisions_list': revisions})
|
||||
return render(request, 'logs/stats_logs.html', {'revisions_list': revisions})
|
||||
|
||||
@login_required
|
||||
@permission_required('bureau')
|
||||
|
|
Loading…
Reference in a new issue