From 8e974cc82dd3a7ed85787846f1e89dba416356b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Sun, 10 Sep 2017 01:07:53 +0000 Subject: [PATCH] =?UTF-8?q?Calcul=20la=20date=20dans=20views=20pour=20affi?= =?UTF-8?q?chage=20plus=20condens=C3=A9=20+=20pr=C3=A9filtre=20les=20r?= =?UTF-8?q?=C3=A9visions=20Si=20quelqu'un=20sait=20faire=20le=20pr=C3=A9fi?= =?UTF-8?q?ltre=20avec=20des=20request=20de=20type=20.filter=20je=20suis?= =?UTF-8?q?=20preneur.=20J'ai=20peur=20que=20la=20solution=20actuelle=20so?= =?UTF-8?q?it=20lente=20pour=20un=20grand=20nombre=20d'event=20(tous=20par?= =?UTF-8?q?s=C3=A9s)=20Mais=20de=20toute=20fa=C3=A7on=20le=20filtre=20est?= =?UTF-8?q?=20oblig=C3=A9=20d'=C3=AAtre=20dans=20views?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logs/templates/logs/aff_summary.html | 14 +++++++------- logs/views.py | 11 ++++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/logs/templates/logs/aff_summary.html b/logs/templates/logs/aff_summary.html index 57cf56e5..c20bf2cb 100644 --- a/logs/templates/logs/aff_summary.html +++ b/logs/templates/logs/aff_summary.html @@ -37,24 +37,24 @@ with this program; if not, write to the Free Software Foundation, Inc., {% for revision in revisions_list %} - {% for reversion in revision.version_set.all %} + {% for reversion in revision.revision.version_set.all %} {% if reversion.content_type.name in 'ban,whitelist,user,vente,interface'|slice:',' %} - {{ revision.date_created }} + {{ revision.datetime }} {% if reversion.content_type.name == 'ban' %} - {{ revision.user.get_username }} a banni {{ reversion.object.user.get_username }} ({{ reversion.object.raison }}) + {{ revision.revision.user.get_username }} a banni {{ reversion.object.user.get_username }} ({{ reversion.object.raison }}) {% elif reversion.content_type.name == 'whitelist' %} - {{ revision.user.get_username }} a autorisé gracieusement {{ reversion.object.user.get_username }} ({{ reversion.object.raison }}) + {{ revision.revision.user.get_username }} a autorisé gracieusement {{ reversion.object.user.get_username }} ({{ reversion.object.raison }}) {% elif reversion.content_type.name == 'user' %} - {{ revision.user.get_username }} a ajouté {{ reversion.object.get_username }} + {{ revision.revision.user.get_username }} a ajouté {{ reversion.object.get_username }} {% elif reversion.content_type.name == 'vente' %} {{ reversion.object.facture.user.get_username }} a acheté {{ reversion.object.number }}x {{ reversion.object.name }}{% if reversion.object.iscotisation %} (+{{ reversion.object.duration }} mois){% endif %} {% elif reversion.content_type.name == 'interface' %} - {{ revision.user.get_username }} a ajouté une interface à {{ reversion.object.machine.user.get_username }} (MAC : {{ reversion.object.mac_bare }}) + {{ revision.revision.user.get_username }} a ajouté une interface à {{ reversion.object.machine.user.get_username }} (MAC : {{ reversion.object.mac_bare }}) {% endif %} {% if is_bureau %} - + Annuler diff --git a/logs/views.py b/logs/views.py index 4be87899..be24dcac 100644 --- a/logs/views.py +++ b/logs/views.py @@ -69,7 +69,16 @@ def form(ctx, template, request): def index(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') + + revisions_not_filtered = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related('version_set__object') + revisions = [] + for revision in revisions_not_filtered : + reversions = revision.version_set.all() + for reversion in reversions : + if reversion.content_type.name in ['ban', 'whitelist', 'vente', 'cotisation', 'interface', 'machine', 'user'] : + revisions.append( {'datetime':revision.date_created.strftime('%d/%m/%y %H:%M:%S'), 'revision':revision } ) + break + paginator = Paginator(revisions, pagination_number) page = request.GET.get('page') try: