diff --git a/logs/templates/logs/aff_actions.html b/logs/templates/logs/aff_actions.html new file mode 100644 index 00000000..e1ee5734 --- /dev/null +++ b/logs/templates/logs/aff_actions.html @@ -0,0 +1,26 @@ +{% if revisions_list.paginator %} +{% include "pagination.html" with list=revisions_list %} +{% endif %} + +{% load logs_extra %} + + + + + + + + + + + + {% for revision in revisions_list %} + + + + + + + + {% endfor %} +
Objet modifiéType de l'objetModification parDate de modificationCommentaire
{% for reversion in revision.version_set.all %}{{ reversion.object|truncatechars:20 }}{% endfor %}{% for reversion in revision.version_set.all %}{{ reversion.object|classname }}{% endfor %}{{ revision.user }}{{ revision.date_created }}{{ revision.comment }}
diff --git a/logs/templates/logs/index.html b/logs/templates/logs/index.html new file mode 100644 index 00000000..ef69c8c0 --- /dev/null +++ b/logs/templates/logs/index.html @@ -0,0 +1,12 @@ +{% extends "logs/sidebar.html" %} +{% load bootstrap3 %} + +{% block title %}Statistiques{% endblock %} + +{% block content %} +

Actions effectuées

+ {% include "logs/aff_actions.html" with revisions_list=revisions_list %} +
+
+
+ {% endblock %} diff --git a/logs/templates/logs/sidebar.html b/logs/templates/logs/sidebar.html new file mode 100644 index 00000000..aa868933 --- /dev/null +++ b/logs/templates/logs/sidebar.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} + +{% block sidebar %} + {% if is_cableur %} + {% endif %} +{% endblock %} diff --git a/logs/templatetags/__init__.py b/logs/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/logs/templatetags/logs_extra.py b/logs/templatetags/logs_extra.py new file mode 100644 index 00000000..7cb9cf04 --- /dev/null +++ b/logs/templatetags/logs_extra.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + +@register.filter +def classname(obj): + return obj.__class__.__name__ + diff --git a/logs/urls.py b/logs/urls.py new file mode 100644 index 00000000..a3780aa2 --- /dev/null +++ b/logs/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url + +from . import views + +urlpatterns = [ + url(r'^$', views.index, name='index'), +] diff --git a/logs/views.py b/logs/views.py index 28002783..fd55a715 100644 --- a/logs/views.py +++ b/logs/views.py @@ -1,2 +1,36 @@ -from django.shortcuts import render +# App de gestion des statistiques pour re2o +# Gabriel Détraz +# Gplv2 +from django.http import HttpResponse +from django.shortcuts import render, redirect +from django.shortcuts import render_to_response, get_object_or_404 +from django.core.context_processors import csrf +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger +from django.template import Context, RequestContext, loader +from django.contrib import messages +from django.contrib.auth.decorators import login_required, permission_required +from django.db.models import ProtectedError +from django.forms import ValidationError +from django.db import transaction + +from reversion.models import Revision +from reversion.models import Version + +from re2o.settings import PAGINATION_NUMBER, PAGINATION_LARGE_NUMBER + +@login_required +@permission_required('cableur') +def index(request): + revisions = Revision.objects.all().order_by('date_created').reverse() + paginator = Paginator(revisions, PAGINATION_NUMBER) + page = request.GET.get('page') + try: + revisions = paginator.page(page) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + revisions = paginator.page(1) + 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}) diff --git a/re2o/urls.py b/re2o/urls.py index 00d07d52..14d1d65b 100644 --- a/re2o/urls.py +++ b/re2o/urls.py @@ -28,5 +28,5 @@ urlpatterns = [ url(r'^cotisations/', include('cotisations.urls', namespace='cotisations')), url(r'^machines/', include('machines.urls', namespace='machines')), url(r'^topologie/', include('topologie.urls', namespace='topologie')), - #url(r'^logs/', include('logs.urls', namespace='logs')), + url(r'^logs/', include('logs.urls', namespace='logs')), ] diff --git a/templates/base.html b/templates/base.html index 09e05af3..2489ba2a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -35,7 +35,7 @@
  • Machines
  • Cotisations
  • Topologie
  • -
  • Statistiques
  • +
  • Statistiques
  • {% endif %}