diff --git a/users/admin.py b/users/admin.py
index 87c3620..0b054b0 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -19,7 +19,8 @@ class RightAdmin(VersionAdmin):
class ClefAdmin(VersionAdmin):
- list_display = ('nom', 'proprio')
+ list_display = ('nom', 'proprio', 'commentaire')
+ # TODO order by nom
class AdhesionAdmin(VersionAdmin):
diff --git a/users/forms.py b/users/forms.py
index 8a4a5c9..74d85c8 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -49,25 +49,6 @@ class PasswordForm(ModelForm):
fields = ['password']
-class StateForm(ModelForm):
- class Meta:
- model = User
- fields = ['is_active']
-
-
-class ClefForm(ModelForm):
- class Meta:
- model = Clef
- fields = '__all__'
-
-
-class BaseClefForm(ClefForm):
- class Meta(ClefForm.Meta):
- fields = [
- 'commentaire',
- ]
-
-
class AdhesionForm(ModelForm):
adherent = forms.ModelMultipleChoiceField(User.objects.all(), widget=forms.CheckboxSelectMultiple, required=False)
@@ -93,23 +74,3 @@ class DelRightForm(Form):
def __init__(self, right, *args, **kwargs):
super(DelRightForm, self).__init__(*args, **kwargs)
self.fields['rights'].queryset = Right.objects.filter(right=right)
-
-
-class ListRightForm(ModelForm):
- class Meta:
- model = ListRight
- fields = ['listright', 'details']
-
- def __init__(self, *args, **kwargs):
- super(ListRightForm, self).__init__(*args, **kwargs)
- self.fields['listright'].label = 'Nom du droit/groupe'
-
-
-class NewListRightForm(ListRightForm):
- class Meta(ListRightForm.Meta):
- fields = '__all__'
-
-
-class DelListRightForm(Form):
- listrights = forms.ModelMultipleChoiceField(queryset=ListRight.objects.all(), label="Droits actuels",
- widget=forms.CheckboxSelectMultiple)
diff --git a/users/models.py b/users/models.py
index 26955aa..4cf7eac 100644
--- a/users/models.py
+++ b/users/models.py
@@ -48,9 +48,6 @@ class User(AbstractUser):
except Right.DoesNotExist:
return False
- def has_right(self, right):
- return Right.objects.filter(user=self).filter(right=ListRight.objects.get(listright=right)).exists()
-
@property
def is_adherent(self):
last_adh_year = Adhesion.objects.all().order_by('annee_debut').reverse().first()
diff --git a/users/templates/users/aff_clef.html b/users/templates/users/aff_clef.html
index 6034ad9..88888f6 100644
--- a/users/templates/users/aff_clef.html
+++ b/users/templates/users/aff_clef.html
@@ -1,48 +1,24 @@
{% 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 %}
-
-
-
- Clef
- Propriétaire
- Commentaire
-
-
-
- {% for clef in clef_list %}
+
+
+
+ Clef
+ Propriétaire
+ Commentaire
+
+
+
+ {% for clef in clef_list %}
{{ clef.nom }}
- {{ clef.proprio }}
- {{ clef.commentaire }}
+ {{ clef.proprio }}
+ {{ clef.commentaire }}
- {% include 'buttons/edit.html' with href='users:edit-clef' id=clef.id %}
- {% if is_bureau %}
- {% include 'buttons/suppr.html' with href='users:del-clef' id=clef.id %}
- {% endif %}
{% include 'buttons/history.html' with href='users:history' name='clef' id=clef.id %}
- {% endfor %}
-
+ {% endfor %}
+
diff --git a/users/templates/users/aff_listright.html b/users/templates/users/aff_listright.html
deleted file mode 100644
index 0b88a4a..0000000
--- a/users/templates/users/aff_listright.html
+++ /dev/null
@@ -1,46 +0,0 @@
-{% 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 %}
-
-
-
-
- Droit
- Details
-
-
-
-
- {% for listright in listright_list %}
-
- {{ listright.listright }}
- {{ listright.details }}
-
- {% if is_bureau %}
- {% include 'buttons/edit.html' with href='users:edit-listright' id=listright.id %}
- {% endif %}
- {% include 'buttons/history.html' with href='users:history' name='listright' id=listright.id %}
-
-
- {% endfor %}
-
diff --git a/users/templates/users/index_clef.html b/users/templates/users/index_clef.html
index a4b0263..cc699e2 100644
--- a/users/templates/users/index_clef.html
+++ b/users/templates/users/index_clef.html
@@ -1,39 +1,11 @@
{% 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.
+SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
-{% load bootstrap3 %}
-
{% block title %}Clef{% endblock %}
{% block content %}
Liste des clef
- {% if is_bureau %}
- Ajouter une clef
- {% endif %}
{% include "users/aff_clef.html" with clef_list=clef_list %}
-
-
-
{% endblock %}
diff --git a/users/templates/users/index_listright.html b/users/templates/users/index_listright.html
deleted file mode 100644
index 42eaaf3..0000000
--- a/users/templates/users/index_listright.html
+++ /dev/null
@@ -1,40 +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 %}
- Liste des droits
- {% if is_bureau %}
- Ajouter un droit ou groupe
- Supprimer un ou plusieurs droits/groupes
- {% endif %}
- {% include "users/aff_listright.html" with listright_list=listright_list %}
-
-
-
-{% endblock %}
diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html
index 9f9b4a1..68f63af 100644
--- a/users/templates/users/profil.html
+++ b/users/templates/users/profil.html
@@ -39,10 +39,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Changer le mot de passe
{% if is_bureau %}
-
-
- Changer le statut
-
Ajouter un droit
diff --git a/users/templates/users/sidebar.html b/users/templates/users/sidebar.html
index 8e7f115..9b3a6a2 100644
--- a/users/templates/users/sidebar.html
+++ b/users/templates/users/sidebar.html
@@ -44,10 +44,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Adhesions
-
-
- Droits
-
Clef
diff --git a/users/urls.py b/users/urls.py
index 1bf6ceb..92239e4 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -10,18 +10,10 @@ 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'^state/(?P[0-9]+)$', views.state, name='state'),
url(r'^password/(?P[0-9]+)$', views.password, name='password'),
url(r'^profil/(?P[0-9]+)$', 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'^add_listright/$', views.add_listright, name='add-listright'),
- url(r'^edit_listright/(?P[0-9]+)$', views.edit_listright, name='edit-listright'),
- url(r'^del_listright/$', views.del_listright, name='del-listright'),
- url(r'^index_listright/$', views.index_listright, name='index-listright'),
- url(r'^add_clef/$', views.add_clef, name='add-clef'),
- url(r'^edit_clef/(?P[0-9]+)$', views.edit_clef, name='edit-clef'),
- url(r'^del_clef/(?P[0-9]+)$', views.del_clef, name='del-clef'),
url(r'^index_clef/$', views.index_clef, name='index-clef'),
url(r'^history/(?Pclef)/(?P[0-9]+)$', views.history, name='history'),
url(r'^add_adhesion/$', views.add_adhesion, name='add-adhesion'),
@@ -33,7 +25,6 @@ urlpatterns = [
url(r'^del_right/$', views.del_right, name='del-right'),
url(r'^process/(?P[a-z0-9]{32})/$', views.process, name='process'),
url(r'^history/(?Puser)/(?P[0-9]+)$', views.history, name='history'),
- url(r'^history/(?Plistright)/(?P[0-9]+)$', views.history, name='history'),
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 ef4b2ba..c064506 100644
--- a/users/views.py
+++ b/users/views.py
@@ -9,7 +9,6 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.urlresolvers import reverse
from django.db import IntegrityError
from django.db import transaction
-from django.db.models import ProtectedError
from django.shortcuts import get_object_or_404, render, redirect
from django.template import loader
from django.template.context_processors import csrf
@@ -20,9 +19,9 @@ from reversion.models import Version
from med.settings import REQ_EXPIRE_STR, EMAIL_FROM, ASSO_NAME, ASSO_EMAIL, SITE_NAME, PAGINATION_NUMBER
from media.models import Emprunt
from users.decorators import user_is_in_campus
-from users.forms import DelListRightForm, NewListRightForm, ListRightForm, RightForm, DelRightForm
-from users.forms import InfoForm, BaseInfoForm, StateForm, ClefForm, AdhesionForm
+from users.forms import InfoForm, BaseInfoForm, AdhesionForm
from users.forms import PassForm
+from users.forms import RightForm, DelRightForm
from users.models import User, Request, ListRight, Right, Clef, Adhesion
@@ -111,26 +110,6 @@ def edit_info(request, userid):
return form({'userform': user}, 'users/user.html', request)
-@login_required
-@permission_required('bureau')
-def state(request, userid):
- """ Changer l'etat actif/desactivé/archivé d'un user, need droit bureau """
- try:
- user = User.objects.get(pk=userid)
- except User.DoesNotExist:
- messages.error(request, "Utilisateur inexistant")
- return redirect("/users/")
- state = StateForm(request.POST or None, instance=user)
- if state.is_valid():
- with transaction.atomic(), reversion.create_revision():
- state.save()
- reversion.set_user(request.user)
- reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in state.changed_data))
- messages.success(request, "Etat changé avec succès")
- return redirect("/users/profil/" + userid)
- return form({'userform': state}, 'users/user.html', request)
-
-
@login_required
def password(request, userid):
""" Reinitialisation d'un mot de passe à partir de l'userid,
@@ -150,64 +129,6 @@ def password(request, userid):
return form({'userform': u_form}, 'users/user.html', request)
-@login_required
-@permission_required('bureau')
-def add_listright(request):
- """ Ajouter un droit/groupe, nécessite droit bureau.
- Obligation de fournir un gid pour la synchro ldap, unique """
- listright = NewListRightForm(request.POST or None)
- if listright.is_valid():
- with transaction.atomic(), reversion.create_revision():
- listright.save()
- reversion.set_user(request.user)
- reversion.set_comment("Création")
- messages.success(request, "Le droit/groupe a été ajouté")
- return redirect("/users/index_listright/")
- return form({'userform': listright}, 'users/user.html', request)
-
-
-@login_required
-@permission_required('bureau')
-def edit_listright(request, listrightid):
- """ Editer un groupe/droit, necessite droit bureau, à partir du listright id """
- try:
- listright_instance = ListRight.objects.get(pk=listrightid)
- except ListRight.DoesNotExist:
- messages.error(request, u"Entrée inexistante")
- return redirect("/users/")
- listright = ListRightForm(request.POST or None, instance=listright_instance)
- if listright.is_valid():
- with transaction.atomic(), reversion.create_revision():
- listright.save()
- reversion.set_user(request.user)
- reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in listright.changed_data))
- messages.success(request, "Droit modifié")
- return redirect("/users/index_listright/")
- return form({'userform': listright}, 'users/user.html', request)
-
-
-@login_required
-@permission_required('bureau')
-def del_listright(request):
- """ Supprimer un ou plusieurs groupe, possible si il est vide, need droit bureau """
- listright = DelListRightForm(request.POST or None)
- if listright.is_valid():
- listright_dels = listright.cleaned_data['listrights']
- for listright_del in listright_dels:
- try:
- with transaction.atomic(), reversion.create_revision():
- listright_del.delete()
- reversion.set_comment("Destruction")
- messages.success(request, "Le droit/groupe a été supprimé")
- except ProtectedError:
- messages.error(
- request,
- "L'établissement %s est affecté à au moins un user, \
- vous ne pouvez pas le supprimer" % listright_del)
- return redirect("/users/index_listright/")
- return form({'userform': listright}, 'users/user.html', request)
-
-
@login_required
@permission_required('bureau')
def add_right(request, userid):
@@ -253,64 +174,6 @@ def del_right(request):
return form({'userform': user_right_list}, 'users/del_right.html', request)
-@login_required
-@permission_required('perm')
-def index_listright(request):
- """ Affiche l'ensemble des droits , need droit perm """
- listright_list = ListRight.objects.order_by('listright')
- return render(request, 'users/index_listright.html', {'listright_list': listright_list})
-
-
-@login_required
-@permission_required('bureau')
-def add_clef(request):
- clef = ClefForm(request.POST or None)
- if clef.is_valid():
- with transaction.atomic(), reversion.create_revision():
- clef.save()
- reversion.set_user(request.user)
- reversion.set_comment("Création")
- messages.success(request, "La clef a été ajouté")
- return redirect("/users/index_clef/")
- return form({'userform': clef}, 'users/user.html', request)
-
-
-@user_is_in_campus
-def edit_clef(request, clefid):
- try:
- clef_instance = Clef.objects.get(pk=clefid)
- except Clef.DoesNotExist:
- messages.error(request, u"Entrée inexistante")
- return redirect("/users/index_clef/")
- clef = ClefForm(request.POST or None, instance=clef_instance)
- if clef.is_valid():
- with transaction.atomic(), reversion.create_revision():
- clef.save()
- if request.user.is_authenticated:
- reversion.set_user(request.user)
- reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in clef.changed_data))
- messages.success(request, "Clef modifié")
- return redirect("/users/index_clef/")
- return form({'userform': clef}, 'users/user.html', request)
-
-
-@login_required
-@permission_required('bureau')
-def del_clef(request, clefid):
- try:
- clef_instance = Clef.objects.get(pk=clefid)
- except Clef.DoesNotExist:
- messages.error(request, u"Entrée inexistante")
- return redirect("/users/index_clef/")
- if request.method == "POST":
- with transaction.atomic(), reversion.create_revision():
- clef_instance.delete()
- reversion.set_user(request.user)
- messages.success(request, "La clef a été détruite")
- return redirect("/users/index_clef")
- return form({'objet': clef_instance, 'objet_name': 'clef'}, 'users/delete.html', request)
-
-
@user_is_in_campus
def index_clef(request):
clef_list = Clef.objects.all().order_by('nom')
@@ -444,12 +307,6 @@ def history(request, object, id):
except Adhesion.DoesNotExist:
messages.error(request, "Utilisateur inexistant")
return redirect("/users/")
- elif object == 'listright':
- try:
- object_instance = ListRight.objects.get(pk=id)
- except ListRight.DoesNotExist:
- messages.error(request, "Droit inexistant")
- return redirect("/users/")
else:
messages.error(request, "Objet inconnu")
return redirect("/users/")