diff --git a/logs/templates/logs/aff_actions.html b/logs/templates/logs/aff_stats_logs.html similarity index 100% rename from logs/templates/logs/aff_actions.html rename to logs/templates/logs/aff_stats_logs.html diff --git a/logs/templates/logs/aff_summary.html b/logs/templates/logs/aff_summary.html new file mode 100644 index 00000000..9b791dfd --- /dev/null +++ b/logs/templates/logs/aff_summary.html @@ -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 %} + + + + + + + + + + {% for v in versions_list %} + {% if v.version.content_type.model == 'ban' %} + + + + {% if is_bureau %} + + {% endif %} + + {% elif v.version.content_type.model == 'whitelist' %} + + + + {% if is_bureau %} + + {% endif %} + + {% elif v.version.content_type.model == 'user' %} + + + + {% if is_bureau %} + + {% endif %} + + {% elif v.version.content_type.model == 'vente' %} + + + + {% if is_bureau %} + + {% endif %} + + {% elif v.version.content_type.model == 'interface' %} + + + + {% if is_bureau %} + + {% endif %} + + {% endif %} + {% endfor %} +
DateModification
{{ v.datetime }} + {{ v.username }} a banni + {{ v.version.object.user.get_username }} + ( + {% if v.version.object.raison == '' %} + Aucune raison + {% else %} + {{ v.version.object.raison }} + {% endif %} + ) + + + + Annuler + +
{{ v.datetime }} + {{ v.username }} a autorisé gracieusement + {{ v.version.object.user.get_username }} + ( + {% if v.version.object.raison == '' %} + Aucune raison + {% else %} + {{ v.version.object.raison }} + {% endif %} + ) + + + + Annuler + +
{{ v.datetime }} + {{ v.username }} a mis à jour + {{ v.version.object.get_username }} + {% if v.comment != '' %} + ({{ v.comment }}) + {% endif %} + + + + Annuler + +
{{ v.datetime }} + {{ v.username }} a vendu {{ v.version.object.number }}x {{ v.version.object.name }} à + {{ v.version.object.facture.user.get_username }} + {% if v.version.object.iscotisation %} + (+{{ v.version.object.duration }} mois) + {% endif %} + + + + Annuler + +
{{ v.datetime }} + {{ v.username }} a modifié une interface de + {{ v.version.object.machine.user.get_username }} + {% if v.comment != '' %} + ({{ v.comment }}) + {% endif %} + + + + Annuler + +
+ + diff --git a/logs/templates/logs/index.html b/logs/templates/logs/index.html index 0255672e..a120a531 100644 --- a/logs/templates/logs/index.html +++ b/logs/templates/logs/index.html @@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block content %}

Actions effectuées

- {% include "logs/aff_actions.html" with revisions_list=revisions_list %} + {% include "logs/aff_summary.html" with versions_list=versions_list %}


diff --git a/logs/templates/logs/sidebar.html b/logs/templates/logs/sidebar.html index cd8bc02f..4137741f 100644 --- a/logs/templates/logs/sidebar.html +++ b/logs/templates/logs/sidebar.html @@ -27,6 +27,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block sidebar %} {% if is_cableur %} + + Résumé + + Évènements diff --git a/logs/templates/logs/stats_logs.html b/logs/templates/logs/stats_logs.html new file mode 100644 index 00000000..4db77c68 --- /dev/null +++ b/logs/templates/logs/stats_logs.html @@ -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 %} +

Actions effectuées

+ {% include "logs/aff_stats_logs.html" with revisions_list=revisions_list %} +
+
+
+ {% endblock %} diff --git a/logs/urls.py b/logs/urls.py index 348765d8..3bb41c4a 100644 --- a/logs/urls.py +++ b/logs/urls.py @@ -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[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'), diff --git a/logs/views.py b/logs/views.py index d9bcf9b5..4f3d6622 100644 --- a/logs/views.py +++ b/logs/views.py @@ -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')