Simplify user profile
This commit is contained in:
parent
ef0bd78af5
commit
8a1af4c2b3
|
@ -23,39 +23,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% if revisions_list.paginator %}
|
{% if revisions_list.paginator %}
|
||||||
{% include "pagination.html" with list=revisions_list %}
|
{% include "pagination.html" with list=revisions_list %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% load logs_extra %}
|
{% load logs_extra %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<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>
|
<tr>
|
||||||
<th>Objet modifié</th>
|
<td>{{ reversion.object|truncatechars:20 }}</td>
|
||||||
<th>Type de l'objet</th>
|
<td>{{ reversion.object|classname }}</td>
|
||||||
<th>Modification par</th>
|
<td>{{ revision.user }}</td>
|
||||||
<th>Date de modification</th>
|
<td>{{ revision.date_created }}</td>
|
||||||
<th>Commentaire</th>
|
<td>{{ revision.comment }}</td>
|
||||||
<th></th>
|
|
||||||
</tr>
|
</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 %}
|
{% endfor %}
|
||||||
</table>
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
|
@ -8,6 +8,5 @@ from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.index, name='index'),
|
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'),
|
url(r'^stats_actions/$', views.stats_actions, name='stats-actions'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# 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.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
|
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
|
||||||
from django.db.models import Count
|
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 django.template.context_processors import csrf
|
||||||
from reversion.models import Revision
|
from reversion.models import Revision
|
||||||
|
|
||||||
|
@ -23,7 +22,8 @@ def form(ctx, template, request):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('perm')
|
@permission_required('perm')
|
||||||
def index(request):
|
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')
|
'version_set__object')
|
||||||
paginator = Paginator(revisions, pagination_number)
|
paginator = Paginator(revisions, pagination_number)
|
||||||
page = request.GET.get('page')
|
page = request.GET.get('page')
|
||||||
|
@ -38,27 +38,13 @@ def index(request):
|
||||||
return render(request, 'logs/index.html', {'revisions_list': revisions})
|
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
|
@login_required
|
||||||
@permission_required('perm')
|
@permission_required('perm')
|
||||||
def stats_actions(request):
|
def stats_actions(request):
|
||||||
stats = {
|
stats = {
|
||||||
'Utilisateur': {
|
'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})
|
return render(request, 'logs/stats_users.html', {'stats_list': stats})
|
||||||
|
|
|
@ -53,9 +53,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="myNavbar">
|
<div class="collapse navbar-collapse" id="myNavbar">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li><a href="{% url "users:mon-profil" %}">Mon profil</a></li>
|
<li><a href="{% url "users:profil" %}">Mon profil</a></li>
|
||||||
{% if is_perm %}
|
{% if is_perm %}
|
||||||
<li><a href="{% url "users:index" %}">Utilisateurs</a></li>
|
<li><a href="{% url "users:new-user" %}">Utilisateurs</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li><a href="{% url "media:index" %}">Media</a></li>
|
<li><a href="{% url "media:index" %}">Media</a></li>
|
||||||
{% if is_perm %}
|
{% if is_perm %}
|
||||||
|
|
|
@ -26,12 +26,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block userlinks %}
|
{% block userlinks %}
|
||||||
{# Link to our apps outside of admin #}
|
{# Link to our apps outside of admin #}
|
||||||
<a href="{% url "users:mon-profil" %}">{% trans 'My profile' %}</a> /
|
<a href="{% url "users:profil" %}">{% trans 'My profile' %}</a> /
|
||||||
<a href="{% url "media:index" %}">Media</a> /
|
<a href="{% url "media:index" %}">Media</a> /
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
{% if is_perm %}
|
{% if is_perm %}
|
||||||
<a href="{% url "users:index" %}">Utilisateurs</a> /
|
<a href="{% url "users:new-user" %}">Nouveau utilisateur</a> /
|
||||||
<a href="{% url "logs:index" %}">Statistiques</a> /
|
<a href="{% url "logs:index" %}">Statistiques</a> /
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -35,16 +35,3 @@ class BaseInfoForm(ModelForm):
|
||||||
'telephone',
|
'telephone',
|
||||||
'address',
|
'address',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class InfoForm(BaseInfoForm):
|
|
||||||
class Meta(BaseInfoForm.Meta):
|
|
||||||
fields = [
|
|
||||||
'first_name',
|
|
||||||
'username',
|
|
||||||
'last_name',
|
|
||||||
'email',
|
|
||||||
'telephone',
|
|
||||||
'address',
|
|
||||||
'maxemprunt',
|
|
||||||
]
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
{% comment %}
|
|
||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
{% endcomment %}
|
|
||||||
|
|
||||||
<table class="table table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Clef</th>
|
|
||||||
<th>Propriétaire</th>
|
|
||||||
<th>Commentaire</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
{% for clef in clef_list %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ clef.nom }}</td>
|
|
||||||
<td>{{ clef.proprio }}</td>
|
|
||||||
<td>{{ clef.commentaire }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
|
@ -1,44 +1,23 @@
|
||||||
{% comment %}
|
{% comment %}
|
||||||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
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 %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% if users_list.paginator %}
|
{% if users_list.paginator %}
|
||||||
{% include "pagination.html" with list=users_list %}
|
{% include "pagination.html" with list=users_list %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Prénom</th>
|
<th>Prénom</th>
|
||||||
<th>Nom</th>
|
<th>Nom</th>
|
||||||
<th>Pseudo</th>
|
<th>Pseudo</th>
|
||||||
<th>Mail</th>
|
<th>Mail</th>
|
||||||
<th>Max emprunts</th>
|
<th>Max emprunts</th>
|
||||||
<th>Adhérent</th>
|
<th>Adhérent</th>
|
||||||
<th>Profil</th>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
</thead>
|
{% for user in users_list %}
|
||||||
{% for user in users_list %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.first_name }}</td>
|
<td>{{ user.first_name }}</td>
|
||||||
<td>{{ user.last_name }}</td>
|
<td>{{ user.last_name }}</td>
|
||||||
|
@ -46,13 +25,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<td>{{ user.email }}</td>
|
<td>{{ user.email }}</td>
|
||||||
<td>{{ user.maxemprunt }}</td>
|
<td>{{ user.maxemprunt }}</td>
|
||||||
{% if user.is_adherent %}
|
{% if user.is_adherent %}
|
||||||
<td><font color="green">Oui</font></td>
|
<td><span style="color:green">Oui</span></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><font color="red">Non</font></td>
|
<td><span style="color:red">Non</span></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td><a href="{% url "users:profil" user.id%}" class="btn btn-primary btn-sm" role="button"><i class="glyphicon glyphicon-user"></i></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -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 %}
|
|
||||||
<h2>Users</h2>
|
|
||||||
{% include "users/aff_users.html" with users_list=users_list %}
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
{% extends "users/sidebar.html" %}
|
|
||||||
{% comment %}
|
|
||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
{% endcomment %}
|
|
||||||
|
|
||||||
{% block title %}Clef{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h2>Liste des clef</h2>
|
|
||||||
{% include "users/aff_clef.html" with clef_list=clef_list %}
|
|
||||||
{% endblock %}
|
|
|
@ -1,26 +1,6 @@
|
||||||
{% extends "users/sidebar.html" %}
|
{% extends "base.html" %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
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 %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
|
@ -30,21 +10,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Compte</h2>
|
<h2>Compte</h2>
|
||||||
<div>
|
<div>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' user.id %}">
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' %}">
|
||||||
<i class="glyphicon glyphicon-edit"></i>
|
<i class="glyphicon glyphicon-edit"></i>
|
||||||
Editer
|
Editer
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:password' user.id %}">
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:password' %}">
|
||||||
<i class="glyphicon glyphicon-lock"></i>
|
<i class="glyphicon glyphicon-lock"></i>
|
||||||
Changer le mot de passe
|
Changer le mot de passe
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-info btn-sm" role="button" href="{% url 'users:history' 'user' user.id %}">
|
|
||||||
<i class="glyphicon glyphicon-time"></i>
|
|
||||||
Historique
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<br />
|
<br/>
|
||||||
</p>
|
</p>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -76,17 +52,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<td>{{ user.maxemprunt }}</td>
|
<td>{{ user.maxemprunt }}</td>
|
||||||
<th>Droits</th>
|
<th>Droits</th>
|
||||||
{% if list_droits %}
|
{% if list_droits %}
|
||||||
<td>{% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} - {% endif %} {% endfor %}</td>
|
<td>{% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} -
|
||||||
|
{% endif %} {% endfor %}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>Aucun</td>
|
<td>Aucun</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Statut</th>
|
<th>Statut</th>
|
||||||
{% if user.is_active %}
|
{% if user.is_active %}
|
||||||
<td><font color="green">Actif</font></td>
|
<td><font color="green">Actif</font></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><font color="red">Désactivé</font></td>
|
<td><font color="red">Désactivé</font></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<th>Dernière connexion</th>
|
<th>Dernière connexion</th>
|
||||||
<td>{{ user.last_login }}</td>
|
<td>{{ user.last_login }}</td>
|
||||||
|
@ -94,27 +71,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<tr>
|
<tr>
|
||||||
<th>Adherent pour l'année en cours</th>
|
<th>Adherent pour l'année en cours</th>
|
||||||
{% if user.is_adherent %}
|
{% if user.is_adherent %}
|
||||||
<td><font color="green">Oui</font></td>
|
<td><font color="green">Oui</font></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><font color="red">Non</font></td>
|
<td><font color="red">Non</font></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not user.is_adherent and is_bureau %}
|
{% if not user.is_adherent and is_bureau %}
|
||||||
<th></th>
|
<th></th>
|
||||||
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'users:adherer' user.id %}"><i class="glyphicon glyphicon-flag"></i> Adhérer</a></td>
|
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'users:adherer' user.id %}"><i
|
||||||
|
class="glyphicon glyphicon-flag"></i> Adhérer</a></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h2>Emprunts</h2>
|
<h2>Emprunts</h2>
|
||||||
{% if is_perm or is_bureau %}
|
{% if is_perm or is_bureau %}
|
||||||
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-emprunt' user.id %}"><i class="glyphicon glyphicon-flag"></i> Ajouter</a></h4>
|
<h4><a class="btn btn-primary btn-sm" role="button" href="{% url 'media:add-emprunt' user.id %}"><i
|
||||||
|
class="glyphicon glyphicon-flag"></i> Ajouter</a></h4>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if emprunts_list %}
|
{% if emprunts_list %}
|
||||||
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
|
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Aucun emprunt</p>
|
<p>Aucun emprunt</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -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 %}
|
|
||||||
<a class="list-group-item list-group-item-success" href="{% url "users:new-user" %}">
|
|
||||||
<i class="glyphicon glyphicon-plus"></i>
|
|
||||||
Créer un adhérent
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% if is_perm %}
|
|
||||||
<a class="list-group-item list-group-item-info" href="{% url "users:index" %}">
|
|
||||||
<i class="glyphicon glyphicon-list"></i>
|
|
||||||
Utilisateurs dans la base
|
|
||||||
</a>
|
|
||||||
<a class="list-group-item list-group-item-info" href="{% url "users:index-ajour" %}">
|
|
||||||
<i class="glyphicon glyphicon-list"></i>
|
|
||||||
Adhérents
|
|
||||||
</a>
|
|
||||||
<a class="list-group-item list-group-item-info" href="{% url "users:index-clef" %}">
|
|
||||||
<i class="glyphicon glyphicon-list"></i>
|
|
||||||
Clef
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
|
@ -1,26 +1,6 @@
|
||||||
{% extends "users/sidebar.html" %}
|
{% extends "base.html" %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
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 %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load bootstrap3 %}
|
{% 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 title %}Création et modification d'utilisateur{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% bootstrap_form_errors userform %}
|
{% bootstrap_form_errors userform %}
|
||||||
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form userform %}
|
{% bootstrap_form userform %}
|
||||||
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
|
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
|
||||||
</form>
|
</form>
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -9,15 +9,9 @@ from . import views
|
||||||
app_name = 'users'
|
app_name = 'users'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^new_user/$', views.new_user, name='new-user'),
|
url(r'^new_user/$', views.new_user, name='new-user'),
|
||||||
url(r'^edit_info/(?P<userid>[0-9]+)$', views.edit_info,
|
url(r'^edit_info/$', views.edit_info, name='edit-info'),
|
||||||
name='edit-info'),
|
url(r'^password/$', views.password, name='password'),
|
||||||
url(r'^password/(?P<userid>[0-9]+)$', views.password,
|
url(r'^profil/$', views.profil, name='profil'),
|
||||||
name='password'),
|
|
||||||
url(r'^profil/(?P<userid>[0-9]+)$', views.profil, name='profil'),
|
|
||||||
url(r'^adherer/(?P<userid>[0-9]+)$', views.adherer, name='adherer'),
|
url(r'^adherer/(?P<userid>[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<token>[a-z0-9]{32})/$', views.process, name='process'),
|
url(r'^process/(?P<token>[a-z0-9]{32})/$', views.process, name='process'),
|
||||||
url(r'^$', views.index, name='index'),
|
|
||||||
url(r'^index_ajour/$', views.index_ajour, name='index-ajour'),
|
|
||||||
]
|
]
|
||||||
|
|
124
users/views.py
124
users/views.py
|
@ -5,7 +5,6 @@
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
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 reversion import revisions as reversion
|
||||||
|
|
||||||
from med.settings import ASSO_EMAIL, ASSO_NAME, EMAIL_FROM, \
|
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 media.models import Emprunt
|
||||||
from users.forms import BaseInfoForm, InfoForm
|
from users.forms import BaseInfoForm
|
||||||
from users.forms import PassForm
|
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):
|
def form(ctx, template, request):
|
||||||
|
@ -64,7 +63,7 @@ def reset_passwd_mail(req, request):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('bureau')
|
@permission_required('users.add_user')
|
||||||
def new_user(request):
|
def new_user(request):
|
||||||
"""
|
"""
|
||||||
Vue de création d'un nouvel utilisateur
|
Vue de création d'un nouvel utilisateur
|
||||||
|
@ -89,26 +88,11 @@ def new_user(request):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def edit_info(request, userid):
|
def edit_info(request):
|
||||||
"""
|
"""
|
||||||
Edite un utilisateur à partir de son id,
|
Edite son utilisateur
|
||||||
si l'id est différent de request.user,
|
|
||||||
vérifie la possession du droit admin
|
|
||||||
"""
|
"""
|
||||||
try:
|
user = BaseInfoForm(request.POST or None, instance=request.user)
|
||||||
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)
|
|
||||||
if user.is_valid():
|
if user.is_valid():
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
user.save()
|
user.save()
|
||||||
|
@ -116,99 +100,33 @@ def edit_info(request, userid):
|
||||||
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(
|
||||||
field for field in user.changed_data))
|
field for field in user.changed_data))
|
||||||
messages.success(request, "L'user a bien été modifié")
|
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)
|
return form({'userform': user}, 'users/user.html', request)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def password(request, userid):
|
def password(request):
|
||||||
""" Reinitialisation d'un mot de passe à partir de l'userid,
|
"""
|
||||||
pour self par défaut, pour tous sans droit si droit admin,
|
Reinitialisation d'un mot de passe
|
||||||
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))
|
|
||||||
u_form = PassForm(request.POST or None)
|
u_form = PassForm(request.POST or None)
|
||||||
if u_form.is_valid():
|
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)
|
return form({'userform': u_form}, 'users/user.html', request)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('perm')
|
def profil(request):
|
||||||
def index_clef(request):
|
"""
|
||||||
clef_list = Clef.objects.all().order_by('nom')
|
Voir son profil
|
||||||
return render(request, 'users/index_clef.html', {'clef_list': clef_list})
|
"""
|
||||||
|
emprunts_list = Emprunt.objects.filter(user=request.user)
|
||||||
|
list_droits = Right.objects.filter(user=request.user)
|
||||||
@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)
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
'users/profil.html',
|
'users/profil.html',
|
||||||
{
|
{
|
||||||
'user': users,
|
'user': request.user,
|
||||||
'emprunts_list': emprunts_list,
|
'emprunts_list': emprunts_list,
|
||||||
'list_droits': list_droits,
|
'list_droits': list_droits,
|
||||||
}
|
}
|
||||||
|
@ -216,7 +134,7 @@ def profil(request, userid):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('bureau')
|
@permission_required('users.add_adhesion')
|
||||||
def adherer(request, userid):
|
def adherer(request, userid):
|
||||||
try:
|
try:
|
||||||
users = User.objects.get(pk=userid)
|
users = User.objects.get(pk=userid)
|
||||||
|
|
Loading…
Reference in New Issue