Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Base de données Mediatek
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mediatek
Base de données Mediatek
Commits
8a1af4c2
Verified
Commit
8a1af4c2
authored
Aug 08, 2019
by
erdnaxe
🎇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify user profile
parent
ef0bd78a
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
102 additions
and
412 deletions
+102
-412
logs/templates/logs/aff_actions.html
logs/templates/logs/aff_actions.html
+21
-29
logs/urls.py
logs/urls.py
+0
-1
logs/views.py
logs/views.py
+5
-19
templates/base.html
templates/base.html
+2
-2
theme/templates/admin/base_site.html
theme/templates/admin/base_site.html
+2
-2
users/forms.py
users/forms.py
+0
-13
users/templates/users/aff_clef.html
users/templates/users/aff_clef.html
+0
-20
users/templates/users/aff_users.html
users/templates/users/aff_users.html
+18
-41
users/templates/users/index.html
users/templates/users/index.html
+0
-37
users/templates/users/index_clef.html
users/templates/users/index_clef.html
+0
-11
users/templates/users/profil.html
users/templates/users/profil.html
+22
-46
users/templates/users/sidebar.html
users/templates/users/sidebar.html
+0
-48
users/templates/users/user.html
users/templates/users/user.html
+8
-31
users/urls.py
users/urls.py
+3
-9
users/views.py
users/views.py
+21
-103
No files found.
logs/templates/logs/aff_actions.html
View file @
8a1af4c2
...
...
@@ -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 %}
<table
class=
"table table-striped"
>
<thead>
<table
class=
"table table-striped"
>
<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>
<th>
Objet modifié
</th>
<th>
Type de l'objet
</th>
<th>
Modification par
</th>
<th>
Date de modification
</th>
<th>
Commentaire
</th>
<th></th>
<td>
{{ reversion.object|truncatechars:20 }}
</td>
<td>
{{ reversion.object|classname }}
</td>
<td>
{{ revision.user }}
</td>
<td>
{{ revision.date_created }}
</td>
<td>
{{ revision.comment }}
</td>
</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 %}
</table>
{% endfor %}
</table>
logs/urls.py
View file @
8a1af4c2
...
...
@@ -8,6 +8,5 @@ from . import views
urlpatterns
=
[
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'
),
]
logs/views.py
View file @
8a1af4c2
...
...
@@ -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
re
direct
,
re
nder
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
})
templates/base.html
View file @
8a1af4c2
...
...
@@ -53,9 +53,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
<div
class=
"collapse navbar-collapse"
id=
"myNavbar"
>
<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 %}
<li><a
href=
"{% url "
users:
index
"
%}"
>
Utilisateurs
</a></li>
<li><a
href=
"{% url "
users:
new-user
"
%}"
>
Utilisateurs
</a></li>
{% endif %}
<li><a
href=
"{% url "
media:index
"
%}"
>
Media
</a></li>
{% if is_perm %}
...
...
theme/templates/admin/base_site.html
View file @
8a1af4c2
...
...
@@ -26,12 +26,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endblock %}
{% block userlinks %}
{# 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>
/
{% if user.is_authenticated %}
{% 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>
/
{% endif %}
...
...
users/forms.py
View file @
8a1af4c2
...
...
@@ -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'
,
]
users/templates/users/aff_clef.html
deleted
100644 → 0
View file @
ef0bd78a
{% 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>
users/templates/users/aff_users.html
View file @
8a1af4c2
{% 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 %}
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Prénom
</th>
<th>
Nom
</th>
<th>
Pseudo
</th>
<th>
Mail
</th>
<th>
Max emprunts
</th>
<th>
Adhérent
</th>
<th>
Profil
</th>
</tr>
</thead>
{% for user in users_list %}
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Prénom
</th>
<th>
Nom
</th>
<th>
Pseudo
</th>
<th>
Mail
</th>
<th>
Max emprunts
</th>
<th>
Adhérent
</th>
</tr>
</thead>
{% for user in users_list %}
<tr>
<td>
{{ user.first_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.maxemprunt }}
</td>
{% if user.is_adherent %}
<td><font
color=
"green"
>
Oui
</font
></td>
<td><span
style=
"color:green"
>
Oui
</span
></td>
{% else %}
<td><font
color=
"red"
>
Non
</font
></td>
<td><span
style=
"color:red"
>
Non
</span
></td>
{% 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>
{% endfor %}
</table>
{% endfor %}
</table>
users/templates/users/index.html
deleted
100644 → 0
View file @
ef0bd78a
{% 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 %}
users/templates/users/index_clef.html
deleted
100644 → 0
View file @
ef0bd78a
{% 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 %}
users/templates/users/profil.html
View file @
8a1af4c2
{% 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 %}
<h2>
Compte
</h2>
<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>
Editer
</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>
Changer le mot de passe
</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>
<p>
<br
/>
<br/>
</p>
<table
class=
"table table-striped"
>
<tr>
...
...
@@ -76,17 +52,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>
{{ user.maxemprunt }}
</td>
<th>
Droits
</th>
{% 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 %}
<td>
Aucun
</td>
<td>
Aucun
</td>
{% endif %}
</tr>
<tr>
<th>
Statut
</th>
<tr>
<th>
Statut
</th>
{% if user.is_active %}
<td><font
color=
"green"
>
Actif
</font></td>
<td><font
color=
"green"
>
Actif
</font></td>
{% else %}
<td><font
color=
"red"
>
Désactivé
</font></td>
<td><font
color=
"red"
>
Désactivé
</font></td>
{% endif %}
<th>
Dernière connexion
</th>
<td>
{{ user.last_login }}
</td>
...
...
@@ -94,27 +71,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<th>
Adherent pour l'année en cours
</th>
{% if user.is_adherent %}
<td><font
color=
"green"
>
Oui
</font></td>
<td><font
color=
"green"
>
Oui
</font></td>
{% else %}
<td><font
color=
"red"
>
Non
</font></td>
<td><font
color=
"red"
>
Non
</font></td>
{% endif %}
{% if not user.is_adherent and is_bureau %}
<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>
<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>
{% endif %}
</tr>
</tr>
</table>
<h2>
Emprunts
</h2>
{% 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 %}
{% if emprunts_list %}
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
{% include "media/aff_emprunts.html" with emprunts_list=emprunts_list %}
{% else %}
<p>
Aucun emprunt
</p>
<p>
Aucun emprunt
</p>
{% endif %}
<br
/>
<br
/>
<br
/>
{% endblock %}
users/templates/users/sidebar.html
deleted
100644 → 0
View file @
ef0bd78a
{% 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 %}
users/templates/users/user.html
View file @
8a1af4c2
{% 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 %}
<form
class=
"form"
method=
"post"
>
{% csrf_token %}
{% bootstrap_form userform %}
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
</form>
<br
/>
<br
/>
<br
/>
<form
class=
"form"
method=
"post"
>
{% csrf_token %}
{% bootstrap_form userform %}
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
</form>
{% endblock %}
users/urls.py
View file @
8a1af4c2
...
...
@@ -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<userid>[0-9]+)$'
,
views
.
edit_info
,
name
=
'edit-info'
),
url
(
r
'^password/(?P<userid>[0-9]+)$'
,
views
.
password
,
name
=
'password'
),
url
(
r
'^profil/(?P<userid>[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<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
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^index_ajour/$'
,
views
.
index_ajour
,
name
=
'index-ajour'
),
]
users/views.py
View file @
8a1af4c2
...
...
@@ -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