From 8a1af4c2b3273d926e309005d01a43cb151709bd Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Thu, 8 Aug 2019 16:18:15 +0200 Subject: [PATCH] Simplify user profile --- logs/templates/logs/aff_actions.html | 50 +++++------ logs/urls.py | 1 - logs/views.py | 24 ++--- templates/base.html | 4 +- theme/templates/admin/base_site.html | 4 +- users/forms.py | 13 --- users/templates/users/aff_clef.html | 20 ----- users/templates/users/aff_users.html | 59 ++++-------- users/templates/users/index.html | 37 -------- users/templates/users/index_clef.html | 11 --- users/templates/users/profil.html | 68 +++++--------- users/templates/users/sidebar.html | 48 ---------- users/templates/users/user.html | 39 ++------ users/urls.py | 12 +-- users/views.py | 124 +++++--------------------- 15 files changed, 102 insertions(+), 412 deletions(-) delete mode 100644 users/templates/users/aff_clef.html delete mode 100644 users/templates/users/index.html delete mode 100644 users/templates/users/index_clef.html delete mode 100644 users/templates/users/sidebar.html diff --git a/logs/templates/logs/aff_actions.html b/logs/templates/logs/aff_actions.html index 3550414..7e70d21 100644 --- a/logs/templates/logs/aff_actions.html +++ b/logs/templates/logs/aff_actions.html @@ -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 %} - - +
+ + + + + + + + + + + {% for revision in revisions_list %} + {% for reversion in revision.version_set.all %} - - - - - - + + + + + - - {% for revision in revisions_list %} - {% for reversion in revision.version_set.all %} - - - - - - - {% if is_bureau %} - - {% endif %} - - {% endfor %} {% endfor %} -
Objet modifiéType de l'objetModification parDate de modificationCommentaire
Objet modifiéType de l'objetModification parDate de modificationCommentaire{{ reversion.object|truncatechars:20 }}{{ reversion.object|classname }}{{ revision.user }}{{ revision.date_created }}{{ revision.comment }}
{{ reversion.object|truncatechars:20 }}{{ reversion.object|classname }}{{ revision.user }}{{ revision.date_created }}{{ revision.comment }} - - - Annuler - -
+ {% endfor %} + diff --git a/logs/urls.py b/logs/urls.py index f0661ac..533fe25 100644 --- a/logs/urls.py +++ b/logs/urls.py @@ -8,6 +8,5 @@ from . import views urlpatterns = [ url(r'^$', views.index, name='index'), - url(r'^revert_action/(?P[0-9]+)$', views.revert_action, name='revert-action'), url(r'^stats_actions/$', views.stats_actions, name='stats-actions'), ] diff --git a/logs/views.py b/logs/views.py index 985ded9..b1c32a5 100644 --- a/logs/views.py +++ b/logs/views.py @@ -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}) diff --git a/templates/base.html b/templates/base.html index feec227..69e5e5b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -53,9 +53,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,