diff --git a/logs/templates/logs/aff_summary.html b/logs/templates/logs/aff_summary.html index 69d64033..8fe646d7 100644 --- a/logs/templates/logs/aff_summary.html +++ b/logs/templates/logs/aff_summary.html @@ -36,76 +36,51 @@ with this program; if not, write to the Free Software Foundation, Inc., - {% for revision in revisions_list %} - {% for reversion in revision.revision.version_set.all %} - {% if reversion.content_type.name in 'ban,whitelist,user,vente,interface'|slice:',' %} - - {{ revision.datetime }} - {% if reversion.content_type.name == 'ban' %} - - {% if revision.revision.user.et_username %} - {{ revision.revision.user.get_username }} - {% else %} - ? - {% endif %} - a banni - {{ reversion.object.user.get_username }} - ({{ reversion.object.raison }}) - - {% elif reversion.content_type.name == 'whitelist' %} - - {% if revision.revision.user.get_username %} - {{ revision.revision.user.get_username }} - {% else %} - ? - {% endif %} - a autorisé gracieusement - {{ reversion.object.user.get_username }} - ({{ reversion.object.raison }}) - - {% elif reversion.content_type.name == 'user' %} - - {% if revision.revision.user.get_username %} - {{ revision.revision.user.get_username }} - {% else %} - ? - {% endif %} - 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' %} - - {% if revision.revision.user.get_username %} - {{ revision.revision.user.get_username }} - {% else %} - ? - {% endif %} - a ajouté une interface à - {{ reversion.object.machine.user.get_username }} - (MAC : {{ reversion.object.mac_bare }}) - - {% endif %} - {% if is_bureau %} - - - - Annuler - - - {% endif %} - - {% endif %} - {% endfor %} - {% endfor %} + {% for rev in reversions_list %} + + {{ rev.datetime }} + {% if rev.rev.content_type.name == 'ban' %} + + {{ rev.username }} a banni + {{ rev.rev.object.user.get_username }} + ({{ rev.rev.object.raison }}) + + {% elif rev.rev.content_type.name == 'whitelist' %} + + {{ rev.username }} a autorisé gracieusement + {{ rev.rev.object.user.get_username }} + ({{ rev.rev.object.raison }}) + + {% elif rev.rev.content_type.name == 'user' %} + + {{ rev.username }} a ajouté + {{ rev.rev.object.get_username }} + + {% elif rev.rev.content_type.name == 'vente' %} + + {{ rev.rev.object.facture.user.get_username }} + a acheté {{ rev.rev.object.number }}x {{ rev.rev.object.name }} + {% if rev.rev.object.iscotisation %} + (+{{ rev.rev.object.duration }} mois) + {% endif %} + + {% elif rev.rev.content_type.name == 'interface' %} + + {{ rev.username }} a ajouté une interface à + {{ rev.rev.object.machine.user.get_username }} + (MAC : {{ rev.rev.object.mac_bare }}) + + {% endif %} + {% if is_bureau %} + + + + Annuler + + + {% endif %} + + {% endfor %} diff --git a/logs/templates/logs/index.html b/logs/templates/logs/index.html index baeb1cd7..487f924e 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_summary.html" with revisions_list=revisions_list %} + {% include "logs/aff_summary.html" with reversions_list=reversions_list %}


diff --git a/logs/views.py b/logs/views.py index be24dcac..886f8dc2 100644 --- a/logs/views.py +++ b/logs/views.py @@ -70,26 +70,31 @@ def index(request): options, created = GeneralOption.objects.get_or_create() pagination_number = options.pagination_number - 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 } ) + revisions = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related('version_set__object') + reversions = [] + for revision in revisions : + for reversion in revision.version_set.all() : + if reversion.content_type.name in ['ban', 'whitelist', 'vente', 'cotisation', 'interface', 'user'] : + reversions.append( + {'id' : revision.id, + 'datetime': revision.date_created.strftime('%d/%m/%y %H:%M:%S'), + 'username': revision.user.get_username() if revision.user else '?', + 'user_id': revision.user_id, + 'rev': reversion } + ) break - paginator = Paginator(revisions, pagination_number) + paginator = Paginator(reversions, pagination_number) page = request.GET.get('page') try: - revisions = paginator.page(page) + reversions = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. - revisions = paginator.page(1) + reversions = 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}) + reversions = paginator.page(paginator.num_pages) + return render(request, 'logs/index.html', {'reversions_list': reversions}) @login_required @permission_required('cableur')