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 %}
-
-
+
+
+
+ Objet modifié |
+ Type de l'objet |
+ Modification par |
+ Date de modification |
+ Commentaire |
+ |
+
+
+ {% for revision in revisions_list %}
+ {% for reversion in revision.version_set.all %}
- Objet modifié |
- Type de l'objet |
- Modification par |
- Date de modification |
- Commentaire |
- |
+ {{ reversion.object|truncatechars:20 }} |
+ {{ reversion.object|classname }} |
+ {{ revision.user }} |
+ {{ revision.date_created }} |
+ {{ revision.comment }} |
-
- {% for revision in revisions_list %}
- {% for reversion in revision.version_set.all %}
-
- {{ reversion.object|truncatechars:20 }} |
- {{ reversion.object|classname }} |
- {{ revision.user }} |
- {{ revision.date_created }} |
- {{ revision.comment }} |
- {% if is_bureau %}
-
-
-
- Annuler
-
- |
- {% endif %}
-
- {% endfor %}
{% endfor %}
-
+ {% 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.,
- - Mon profil
+ - Mon profil
{% if is_perm %}
- - Utilisateurs
+ - Utilisateurs
{% endif %}
- Media
{% if is_perm %}
diff --git a/theme/templates/admin/base_site.html b/theme/templates/admin/base_site.html
index 6841a32..1199750 100644
--- a/theme/templates/admin/base_site.html
+++ b/theme/templates/admin/base_site.html
@@ -26,12 +26,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endblock %}
{% block userlinks %}
{# Link to our apps outside of admin #}
- {% trans 'My profile' %} /
+ {% trans 'My profile' %} /
Media /
{% if user.is_authenticated %}
{% if is_perm %}
- Utilisateurs /
+ Nouveau utilisateur /
Statistiques /
{% endif %}
diff --git a/users/forms.py b/users/forms.py
index 0dd319a..ed6d5b8 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -35,16 +35,3 @@ class BaseInfoForm(ModelForm):
'telephone',
'address',
]
-
-
-class InfoForm(BaseInfoForm):
- class Meta(BaseInfoForm.Meta):
- fields = [
- 'first_name',
- 'username',
- 'last_name',
- 'email',
- 'telephone',
- 'address',
- 'maxemprunt',
- ]
diff --git a/users/templates/users/aff_clef.html b/users/templates/users/aff_clef.html
deleted file mode 100644
index 72d7b38..0000000
--- a/users/templates/users/aff_clef.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{% comment %}
-SPDX-License-Identifier: GPL-3.0-or-later
-{% endcomment %}
-
-
-
-
- Clef |
- Propriétaire |
- Commentaire |
-
-
- {% for clef in clef_list %}
-
- {{ clef.nom }} |
- {{ clef.proprio }} |
- {{ clef.commentaire }} |
-
- {% endfor %}
-
diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html
index 4248ec3..a1586d0 100644
--- a/users/templates/users/aff_users.html
+++ b/users/templates/users/aff_users.html
@@ -1,44 +1,23 @@
{% comment %}
-Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-se veut agnostique au réseau considéré, de manière à être installable en
-quelques clics.
-
-Copyright © 2017 Gabriel Détraz
-Copyright © 2017 Goulven Kermarec
-Copyright © 2017 Augustin Lemesle
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% if users_list.paginator %}
-{% include "pagination.html" with list=users_list %}
+ {% include "pagination.html" with list=users_list %}
{% endif %}
-
-
-
- Prénom |
- Nom |
- Pseudo |
- Mail |
- Max emprunts |
- Adhérent |
- Profil |
-
-
- {% for user in users_list %}
+
+
+
+ Prénom |
+ Nom |
+ Pseudo |
+ Mail |
+ Max emprunts |
+ Adhérent |
+
+
+ {% for user in users_list %}
{{ user.first_name }} |
{{ user.last_name }} |
@@ -46,13 +25,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{{ user.email }} |
{{ user.maxemprunt }} |
{% if user.is_adherent %}
- Oui |
+ Oui |
{% else %}
- Non |
+ Non |
{% endif %}
-
- |
- {% endfor %}
-
+ {% endfor %}
+
diff --git a/users/templates/users/index.html b/users/templates/users/index.html
deleted file mode 100644
index 2b6b03a..0000000
--- a/users/templates/users/index.html
+++ /dev/null
@@ -1,37 +0,0 @@
-{% extends "users/sidebar.html" %}
-{% comment %}
-Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-se veut agnostique au réseau considéré, de manière à être installable en
-quelques clics.
-
-Copyright © 2017 Gabriel Détraz
-Copyright © 2017 Goulven Kermarec
-Copyright © 2017 Augustin Lemesle
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-{% endcomment %}
-
-{% load bootstrap3 %}
-
-{% block title %}Utilisateurs{% endblock %}
-
-{% block content %}
- Users
- {% include "users/aff_users.html" with users_list=users_list %}
-
-
-
-{% endblock %}
-
diff --git a/users/templates/users/index_clef.html b/users/templates/users/index_clef.html
deleted file mode 100644
index cc699e2..0000000
--- a/users/templates/users/index_clef.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends "users/sidebar.html" %}
-{% comment %}
-SPDX-License-Identifier: GPL-3.0-or-later
-{% endcomment %}
-
-{% block title %}Clef{% endblock %}
-
-{% block content %}
- Liste des clef
- {% include "users/aff_clef.html" with clef_list=clef_list %}
-{% endblock %}
diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html
index 94541bb..709b605 100644
--- a/users/templates/users/profil.html
+++ b/users/templates/users/profil.html
@@ -1,26 +1,6 @@
-{% extends "users/sidebar.html" %}
+{% extends "base.html" %}
{% comment %}
-Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-se veut agnostique au réseau considéré, de manière à être installable en
-quelques clics.
-
-Copyright © 2017 Gabriel Détraz
-Copyright © 2017 Goulven Kermarec
-Copyright © 2017 Augustin Lemesle
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load bootstrap3 %}
@@ -30,21 +10,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block content %}
Compte
-
+
@@ -76,17 +52,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{{ user.maxemprunt }} |
Droits |
{% if list_droits %}
- {% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} - {% endif %} {% endfor %} |
+ {% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} -
+ {% endif %} {% endfor %} |
{% else %}
- Aucun |
+ Aucun |
{% endif %}
-
- Statut |
+
+ Statut |
{% if user.is_active %}
- Actif |
+ Actif |
{% else %}
- Désactivé |
+ Désactivé |
{% endif %}
Dernière connexion |
{{ user.last_login }} |
@@ -94,27 +71,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Adherent pour l'année en cours |
{% if user.is_adherent %}
- Oui |
+ Oui |
{% else %}
- Non |
+ Non |
{% endif %}
{% if not user.is_adherent and is_bureau %}
- |
- Adhérer |
+ |
+ Adhérer |
{% endif %}
-
+
Emprunts
{% if is_perm or is_bureau %}
-
+
{% endif %}
{% if emprunts_list %}
- {% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
+ {% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
{% else %}
- Aucun emprunt
+ Aucun emprunt
{% endif %}
-
-
-
{% endblock %}
diff --git a/users/templates/users/sidebar.html b/users/templates/users/sidebar.html
deleted file mode 100644
index f72842c..0000000
--- a/users/templates/users/sidebar.html
+++ /dev/null
@@ -1,48 +0,0 @@
-{% extends "base.html" %}
-{% comment %}
-Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-se veut agnostique au réseau considéré, de manière à être installable en
-quelques clics.
-
-Copyright © 2017 Gabriel Détraz
-Copyright © 2017 Goulven Kermarec
-Copyright © 2017 Augustin Lemesle
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-{% endcomment %}
-
-
-{% block sidebar %}
- {% if is_bureau %}
-
-
- Créer un adhérent
-
- {% endif %}
- {% if is_perm %}
-
-
- Utilisateurs dans la base
-
-
-
- Adhérents
-
-
-
- Clef
-
- {% endif %}
-{% endblock %}
diff --git a/users/templates/users/user.html b/users/templates/users/user.html
index bbdc7fc..66cd359 100644
--- a/users/templates/users/user.html
+++ b/users/templates/users/user.html
@@ -1,26 +1,6 @@
-{% extends "users/sidebar.html" %}
+{% extends "base.html" %}
{% comment %}
-Re2o est un logiciel d'administration développé initiallement au rezometz. Il
-se veut agnostique au réseau considéré, de manière à être installable en
-quelques clics.
-
-Copyright © 2017 Gabriel Détraz
-Copyright © 2017 Goulven Kermarec
-Copyright © 2017 Augustin Lemesle
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load bootstrap3 %}
@@ -28,14 +8,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block title %}Création et modification d'utilisateur{% endblock %}
{% block content %}
-{% bootstrap_form_errors userform %}
+ {% bootstrap_form_errors userform %}
-
-
-
-
+
{% endblock %}
diff --git a/users/urls.py b/users/urls.py
index 098a46a..6ffef04 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -9,15 +9,9 @@ from . import views
app_name = 'users'
urlpatterns = [
url(r'^new_user/$', views.new_user, name='new-user'),
- url(r'^edit_info/(?P
[0-9]+)$', views.edit_info,
- name='edit-info'),
- url(r'^password/(?P[0-9]+)$', views.password,
- name='password'),
- url(r'^profil/(?P[0-9]+)$', views.profil, name='profil'),
+ url(r'^edit_info/$', views.edit_info, name='edit-info'),
+ url(r'^password/$', views.password, name='password'),
+ url(r'^profil/$', views.profil, name='profil'),
url(r'^adherer/(?P[0-9]+)$', views.adherer, name='adherer'),
- url(r'^mon_profil/$', views.mon_profil, name='mon-profil'),
- url(r'^index_clef/$', views.index_clef, name='index-clef'),
url(r'^process/(?P[a-z0-9]{32})/$', views.process, name='process'),
- url(r'^$', views.index, name='index'),
- url(r'^index_ajour/$', views.index_ajour, name='index-ajour'),
]
diff --git a/users/views.py b/users/views.py
index a8534a7..18c4802 100644
--- a/users/views.py
+++ b/users/views.py
@@ -5,7 +5,6 @@
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.core.mail import send_mail
-from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.core.urlresolvers import reverse
from django.db import transaction
from django.shortcuts import get_object_or_404, redirect, render
@@ -15,11 +14,11 @@ from django.utils import timezone
from reversion import revisions as reversion
from med.settings import ASSO_EMAIL, ASSO_NAME, EMAIL_FROM, \
- PAGINATION_NUMBER, REQ_EXPIRE_STR, SITE_NAME
+ REQ_EXPIRE_STR, SITE_NAME
from media.models import Emprunt
-from users.forms import BaseInfoForm, InfoForm
+from users.forms import BaseInfoForm
from users.forms import PassForm
-from users.models import Adhesion, Clef, Request, Right, User
+from users.models import Adhesion, Request, Right, User
def form(ctx, template, request):
@@ -64,7 +63,7 @@ def reset_passwd_mail(req, request):
@login_required
-@permission_required('bureau')
+@permission_required('users.add_user')
def new_user(request):
"""
Vue de création d'un nouvel utilisateur
@@ -89,26 +88,11 @@ def new_user(request):
@login_required
-def edit_info(request, userid):
+def edit_info(request):
"""
- Edite un utilisateur à partir de son id,
- si l'id est différent de request.user,
- vérifie la possession du droit admin
+ Edite son utilisateur
"""
- try:
- user = User.objects.get(pk=userid)
- except User.DoesNotExist:
- messages.error(request, "Utilisateur inexistant")
- return redirect("/users/")
- if not request.user.has_perms(('bureau',)) and user != request.user:
- messages.error(request,
- "Vous ne pouvez pas modifier un autre user que vous "
- "sans droit admin")
- return redirect("/users/profil/" + str(request.user.id))
- if not request.user.has_perms(('bureau',)):
- user = BaseInfoForm(request.POST or None, instance=user)
- else:
- user = InfoForm(request.POST or None, instance=user)
+ user = BaseInfoForm(request.POST or None, instance=request.user)
if user.is_valid():
with transaction.atomic(), reversion.create_revision():
user.save()
@@ -116,99 +100,33 @@ def edit_info(request, userid):
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
field for field in user.changed_data))
messages.success(request, "L'user a bien été modifié")
- return redirect("/users/profil/" + userid)
+ return redirect("/users/profil/")
return form({'userform': user}, 'users/user.html', request)
@login_required
-def password(request, userid):
- """ Reinitialisation d'un mot de passe à partir de l'userid,
- pour self par défaut, pour tous sans droit si droit admin,
- pour tous si droit bureau """
- try:
- user = User.objects.get(pk=userid)
- except User.DoesNotExist:
- messages.error(request, "Utilisateur inexistant")
- return redirect("/users/")
- if not request.user.has_perms(('bureau',)) and user != request.user:
- messages.error(request,
- "Vous ne pouvez pas modifier un autre user que vous "
- "sans droit admin")
- return redirect("/users/profil/" + str(request.user.id))
+def password(request):
+ """
+ Reinitialisation d'un mot de passe
+ """
u_form = PassForm(request.POST or None)
if u_form.is_valid():
- return password_change_action(u_form, user, request)
+ return password_change_action(u_form, request.user, request)
return form({'userform': u_form}, 'users/user.html', request)
@login_required
-@permission_required('perm')
-def index_clef(request):
- clef_list = Clef.objects.all().order_by('nom')
- return render(request, 'users/index_clef.html', {'clef_list': clef_list})
-
-
-@login_required
-@permission_required('perm')
-def index(request):
- """ Affiche l'ensemble des users, need droit admin """
- users_list = User.objects.order_by('first_name')
- paginator = Paginator(users_list, PAGINATION_NUMBER)
- page = request.GET.get('page')
- try:
- users_list = paginator.page(page)
- except PageNotAnInteger:
- # If page is not an integer, deliver first page.
- users_list = paginator.page(1)
- except EmptyPage:
- # If page is out of range (e.g. 9999), deliver last page of results.
- users_list = paginator.page(paginator.num_pages)
- return render(request, 'users/index.html', {'users_list': users_list})
-
-
-@login_required
-@permission_required('perm')
-def index_ajour(request):
- """ Affiche l'ensemble des users, need droit admin """
- users_list = Adhesion.objects.all().order_by(
- 'annee_debut').reverse().first().adherent.all().order_by('first_name')
- paginator = Paginator(users_list, PAGINATION_NUMBER)
- page = request.GET.get('page')
- try:
- users_list = paginator.page(page)
- except PageNotAnInteger:
- # If page is not an integer, deliver first page.
- users_list = paginator.page(1)
- except EmptyPage:
- # If page is out of range (e.g. 9999), deliver last page of results.
- users_list = paginator.page(paginator.num_pages)
- return render(request, 'users/index.html', {'users_list': users_list})
-
-
-@login_required
-def mon_profil(request):
- return redirect("/users/profil/" + str(request.user.id))
-
-
-@login_required
-def profil(request, userid):
- try:
- users = User.objects.get(pk=userid)
- except User.DoesNotExist:
- messages.error(request, "Utilisateur inexistant")
- return redirect("/users/")
- if not request.user.has_perms(('perm',)) and users != request.user:
- messages.error(request,
- "Vous ne pouvez pas afficher un autre user "
- "que vous sans droit perm")
- return redirect("/users/profil/" + str(request.user.id))
- emprunts_list = Emprunt.objects.filter(user=users)
- list_droits = Right.objects.filter(user=users)
+def profil(request):
+ """
+ Voir son profil
+ """
+ emprunts_list = Emprunt.objects.filter(user=request.user)
+ list_droits = Right.objects.filter(user=request.user)
return render(
request,
'users/profil.html',
{
- 'user': users,
+ 'user': request.user,
'emprunts_list': emprunts_list,
'list_droits': list_droits,
}
@@ -216,7 +134,7 @@ def profil(request, userid):
@login_required
-@permission_required('bureau')
+@permission_required('users.add_adhesion')
def adherer(request, userid):
try:
users = User.objects.get(pk=userid)