Verified Commit 8a1af4c2 authored by erdnaxe's avatar erdnaxe 🎇

Simplify user profile

parent ef0bd78a
...@@ -23,39 +23,31 @@ with this program; if not, write to the Free Software Foundation, Inc., ...@@ -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 ...@@ -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 @@ ...@@ -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): ...@@ -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): ...@@ -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., ...@@ -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 ...@@ -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): ...@@ -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',
]
{% 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>
{% 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., ...@@ -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>
{% 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 %}
{% 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 %}
{% 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., ...@@ -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., ...@@ -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., ...@@ -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 %}
{% 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 %}
{% 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., ...@@ -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 ...@@ -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'),
] ]
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
from django.contrib import messages from django.contrib import messages