1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2025-06-29 19:11:09 +02:00

Simplify user profile

This commit is contained in:
Alexandre Iooss
2019-08-08 16:18:15 +02:00
parent ef0bd78af5
commit 8a1af4c2b3
15 changed files with 102 additions and 412 deletions

View File

@ -23,39 +23,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% if revisions_list.paginator %}
{% include "pagination.html" with list=revisions_list %}
{% include "pagination.html" with list=revisions_list %}
{% endif %}
{% load logs_extra %}
<table class="table table-striped">
<thead>
<table class="table table-striped">
<thead>
<tr>
<th>Objet modifié</th>
<th>Type de l'objet</th>
<th>Modification par</th>
<th>Date de modification</th>
<th>Commentaire</th>
<th></th>
</tr>
</thead>
{% for revision in revisions_list %}
{% for reversion in revision.version_set.all %}
<tr>
<th>Objet modifié</th>
<th>Type de l'objet</th>
<th>Modification par</th>
<th>Date de modification</th>
<th>Commentaire</th>
<th></th>
<td>{{ reversion.object|truncatechars:20 }}</td>
<td>{{ reversion.object|classname }}</td>
<td>{{ revision.user }}</td>
<td>{{ revision.date_created }}</td>
<td>{{ revision.comment }}</td>
</tr>
</thead>
{% for revision in revisions_list %}
{% for reversion in revision.version_set.all %}
<tr>
<td>{{ reversion.object|truncatechars:20 }}</td>
<td>{{ reversion.object|classname }}</td>
<td>{{ revision.user }}</td>
<td>{{ revision.date_created }}</td>
<td>{{ revision.comment }}</td>
{% if is_bureau %}
<td>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'logs:revert-action' revision.id %}">
<i class="glyphicon glyphicon-remove"></i>
Annuler
</a>
</td>
{% endif %}
</tr>
{% endfor %}
{% endfor %}
</table>
{% endfor %}
</table>

View File

@ -8,6 +8,5 @@ from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^revert_action/(?P<revision_id>[0-9]+)$', views.revert_action, name='revert-action'),
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
]

View File

@ -2,11 +2,10 @@
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db.models import Count
from django.shortcuts import redirect, render
from django.shortcuts import render
from django.template.context_processors import csrf
from reversion.models import Revision
@ -23,7 +22,8 @@ def form(ctx, template, request):
@login_required
@permission_required('perm')
def index(request):
revisions = Revision.objects.all().order_by('date_created').reverse().select_related('user').prefetch_related(
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')
@ -38,27 +38,13 @@ def index(request):
return render(request, 'logs/index.html', {'revisions_list': revisions})
@login_required
@permission_required('bureau')
def revert_action(request, revision_id):
""" Annule l'action en question """
try:
revision = Revision.objects.get(id=revision_id)
except Revision.DoesNotExist:
messages.error(request, u"Revision inexistante")
if request.method == "POST":
revision.revert()
messages.success(request, "L'action a été supprimée")
return redirect("/logs/")
return form({'objet': revision, 'objet_name': revision.__class__.__name__}, 'logs/delete.html', request)
@login_required
@permission_required('perm')
def stats_actions(request):
stats = {
'Utilisateur': {
'Action': User.objects.annotate(num=Count('revision')).order_by('-num')[:40],
'Action': User.objects.annotate(num=Count('revision')).order_by(
'-num')[:40],
},
}
return render(request, 'logs/stats_users.html', {'stats_list': stats})