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
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
20be7fdb
Commit
20be7fdb
authored
Dec 29, 2017
by
Gabriel Detraz
Committed by
root
Jan 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Les can_change deviennent des class method
parent
9f7d994c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
51 deletions
+56
-51
cotisations/models.py
cotisations/models.py
+6
-4
re2o/field_permissions.py
re2o/field_permissions.py
+1
-1
users/models.py
users/models.py
+6
-3
users/templates/users/profil.html
users/templates/users/profil.html
+40
-40
users/views.py
users/views.py
+3
-3
No files found.
cotisations/models.py
View file @
20be7fdb
...
...
@@ -149,11 +149,13 @@ class Facture(FieldPermissionModelMixin, models.Model):
else
:
return
True
,
None
def
can_change_control
(
user
,
*
args
,
**
kwargs
):
return
user
.
has_perms
((
'tresorier'
,)),
"Vous ne pouvez pas éditer le controle sans droit trésorier"
@
classmethod
def
can_change_control
(
cls
,
user_request
,
*
args
,
**
kwargs
):
return
user_request
.
has_perms
((
'tresorier'
,)),
"Vous ne pouvez pas éditer le controle sans droit trésorier"
def
can_change_pdf
(
user
,
*
args
,
**
kwargs
):
return
user
.
has_perms
((
'tresorier'
,)),
"Vous ne pouvez pas éditer une facture sans droit trésorier"
@
classmethod
def
can_change_pdf
(
cls
,
user_request
,
*
args
,
**
kwargs
):
return
user_request
.
has_perms
((
'tresorier'
,)),
"Vous ne pouvez pas éditer une facture sans droit trésorier"
field_permissions
=
{
'control'
:
can_change_control
,
...
...
re2o/field_permissions.py
View file @
20be7fdb
...
...
@@ -42,7 +42,7 @@ class FieldPermissionModelMixin:
# Try to find a user setting that qualifies them for permission.
for
perm
in
checks
:
if
callable
(
perm
):
result
,
reason
=
perm
(
user
=
user
)
result
,
reason
=
perm
(
user
_request
=
user
)
if
result
is
not
None
:
return
result
else
:
...
...
users/models.py
View file @
20be7fdb
...
...
@@ -820,13 +820,16 @@ class User(FieldPermissionModelMixin, AbstractBaseUser):
else
:
return
False
,
u
"Vous ne pouvez éditer un autre utilisateur que vous même"
def
can_change_state
(
user_request
,
*
args
,
**
kwargs
):
@
classmethod
def
can_change_state
(
cls
,
user_request
,
*
args
,
**
kwargs
):
return
user_request
.
has_perms
((
'bureau'
,)),
"Droit bureau requis pour changer l'état"
def
can_change_shell
(
user_request
,
*
args
,
**
kwargs
):
@
classmethod
def
can_change_shell
(
cls
,
user_request
,
*
args
,
**
kwargs
):
return
user_request
.
has_perms
((
'cableur'
,)),
"Droit requis pour changer le shell"
def
can_change_force
(
user_request
,
*
args
,
**
kwargs
):
@
classmethod
def
can_change_force
(
cls
,
user_request
,
*
args
,
**
kwargs
):
return
user_request
.
has_perms
((
'cableur'
,)),
"Droit requis pour forcer le déménagement"
def
can_delete
(
self
,
user_request
,
*
args
,
**
kwargs
):
...
...
users/templates/users/profil.html
View file @
20be7fdb
...
...
@@ -28,25 +28,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block title %}Profil{% endblock %}
{% block content %}
<h2>
{{ user.class_name }}
</h2>
<h2>
{{ user
s
.class_name }}
</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' user
s
.id %}"
>
<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' user
s
.id %}"
>
<i
class=
"glyphicon glyphicon-lock"
></i>
Changer le mot de passe
</a>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:state' user.id %}"
>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:state' user
s
.id %}"
>
<i
class=
"glyphicon glyphicon-flash"
></i>
Changer le statut
</a>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:add-right' user.id %}"
>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:add-right' user
s
.id %}"
>
<i
class=
"glyphicon glyphicon-ok"
></i>
Ajouter un droit
</a>
<a
class=
"btn btn-info btn-sm"
role=
"button"
href=
"{% url 'users:history' 'user' user.id %}"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
href=
"{% url 'users:history' 'user' user
s
.id %}"
>
<i
class=
"glyphicon glyphicon-time"
></i>
Historique
</a>
...
...
@@ -57,58 +57,58 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<table
class=
"table table-striped"
>
<tr>
<th>
Prénom
</th>
<td>
{{ user.name }}
</td>
<td>
{{ user
s
.name }}
</td>
<th>
Nom
</th>
<td>
{{ user.surname }}
</td>
<td>
{{ user
s
.surname }}
</td>
</tr>
<tr>
<th>
Pseudo
</th>
<td>
{{ user.pseudo }}
</td>
<td>
{{ user
s
.pseudo }}
</td>
<th>
E-mail
</th>
<td>
{{ user.email }}
</td>
<td>
{{ user
s
.email }}
</td>
</tr>
<tr>
<th>
Chambre
</th>
<td>
{{ user.room }}
</td>
<td>
{{ user
s
.room }}
</td>
<th>
Téléphone
</th>
<td>
{{ user
.telephone }}
</td>
<td>
{{ users
.telephone }}
</td>
</tr>
<tr>
<th>
École
</th>
<td>
{{ user.school }}
</td>
<td>
{{ user
s
.school }}
</td>
<th>
Commentaire
</th>
<td>
{{ user.comment }}
</td>
<td>
{{ user
s
.comment }}
</td>
</tr>
<tr>
<th>
Date d'inscription
</th>
<td>
{{ user.registered }}
</td>
<td>
{{ user
s
.registered }}
</td>
<th>
Dernière connexion
</th>
<td>
{{ user.last_login }}
</td>
<td>
{{ user
s
.last_login }}
</td>
</tr>
<tr>
<th>
Fin d'adhésion
</th>
{% if user.end_adhesion != None %}
<td><i
class=
"text-success"
>
{{ user.end_adhesion }}
</i></td>
{% if user
s
.end_adhesion != None %}
<td><i
class=
"text-success"
>
{{ user
s
.end_adhesion }}
</i></td>
{% else %}
<td><i
class=
"text-danger"
>
Non adhérent
</i></td>
{% endif %}
<th>
Accès gracieux
</th>
{% if user.end_whitelist != None %}
<td><i
class=
"text-success"
>
{{ user.end_whitelist }}
</i></td>
{% if user
s
.end_whitelist != None %}
<td><i
class=
"text-success"
>
{{ user
s
.end_whitelist }}
</i></td>
{% else %}
<td><i
class=
"text-warning"
>
Aucun
</i></td>
{% endif %}
<tr>
<th>
Bannissement
</th>
{% if user.end_ban != None %}
<td><i
class=
"text-danger"
>
{{ user.end_ban }}
</i></td>
{% if user
s
.end_ban != None %}
<td><i
class=
"text-danger"
>
{{ user
s
.end_ban }}
</i></td>
{% else %}
<td><i
class=
"text-success"
>
Non banni
</i></td>
{% endif %}
<th>
Statut
</th>
{% if user.state == 0 %}
{% if user
s
.state == 0 %}
<td><i
class=
"text-success"
>
Actif
</i></td>
{% elif user.state == 1 %}
{% elif user
s
.state == 1 %}
<td><i
class=
"text-danger"
>
Désactivé
</i></td>
{% else %}
<td><i
class=
"text-warning"
>
Archivé
</i></td>
...
...
@@ -116,8 +116,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr>
<tr>
<th>
Accès internet
</th>
{% if user.has_access == True %}
<td><i
class=
"text-success"
>
Actif (jusqu'au {{ user
.end_access }})
</i></td>
{% if user
s
.has_access == True %}
<td><i
class=
"text-success"
>
Actif (jusqu'au {{ users
.end_access }})
</i></td>
{% else %}
<td><i
class=
"text-danger"
>
Désactivé
</i></td>
{% endif %}
...
...
@@ -131,16 +131,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if user_solde %}
<tr>
<th>
Solde
</th>
<td>
{{ user.solde }} €
</td>
<td>
{{ user
s
.solde }} €
</td>
</tr>
{% endif %}
{% if user
.shell %}
<th>
Shell
</th>
<td>
{{ user
.shell }}
</td>
{% endif %}
{% endif %}
{% if users
.shell %}
<th>
Shell
</th>
<td>
{{ users
.shell }}
</td>
{% endif %}
</table>
{% if user.is_class_club %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:edit-club-admin-members' user.club.id %}"
>
{% if user
s
.is_class_club %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:edit-club-admin-members' user
s
.club.id %}"
>
<i
class=
"glyphicon glyphicon-lock"
></i>
Gérer admin et membres
</a>
...
...
@@ -153,7 +153,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>
Pseudo
</th>
</tr>
</thead>
{% for admin in user.club.administrators.all %}
{% for admin in user
s
.club.administrators.all %}
<tr>
<td>
{{ admin.surname }}
</td>
<td>
{{ admin.name }}
</td>
...
...
@@ -170,7 +170,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>
Pseudo
</th>
</tr>
</thead>
{% for admin in user.club.members.all %}
{% for admin in user
s
.club.members.all %}
<tr>
<td>
{{ admin.surname }}
</td>
<td>
{{ admin.name }}
</td>
...
...
@@ -180,28 +180,28 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</table>
{% endif %}
<h2>
Machines
</h2>
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'machines:new-machine' user.id %}"
><i
class=
"glyphicon glyphicon-phone"
></i>
Ajouter une machine
</a></h4>
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'machines:new-machine' user
s
.id %}"
><i
class=
"glyphicon glyphicon-phone"
></i>
Ajouter une machine
</a></h4>
{% if machines_list %}
{% include "machines/aff_machines.html" with machines_list=machines_list %}
{% else %}
<p>
Aucune machine
</p>
{% endif %}
<h2>
Cotisations
</h2>
<h4>
{% can_create Facture %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'cotisations:new-facture' user
.id %}"
><i
class=
"glyphicon glyphicon-piggy-bank"
></i>
Ajouter une cotisation
</a>
{% acl_end %} {% if user_solde %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'cotisations:credit-solde' user
.id %}"
><i
class=
"glyphicon glyphicon-piggy-bank"
></i>
Modifier le solde
</a>
{% endif%}
</h4>
<h4>
{% can_create Facture %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'cotisations:new-facture' user
s.id %}"
><i
class=
"glyphicon glyphicon-piggy-bank"
></i>
Ajouter une cotisation
</a>
{% acl_end %} {% if user_solde %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'cotisations:credit-solde' users
.id %}"
><i
class=
"glyphicon glyphicon-piggy-bank"
></i>
Modifier le solde
</a>
{% endif%}
</h4>
{% if facture_list %}
{% include "cotisations/aff_cotisations.html" with facture_list=facture_list %}
{% else %}
<p>
Aucune facture
</p>
{% endif %}
<h2>
Bannissements
</h2>
{% can_create Ban %}
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:add-ban' user.id %}"
><i
class=
"glyphicon glyphicon-pushpin"
></i>
Ajouter un bannissement
</a></h4>
{% acl_end %}
{% can_create Ban %}
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:add-ban' user
s
.id %}"
><i
class=
"glyphicon glyphicon-pushpin"
></i>
Ajouter un bannissement
</a></h4>
{% acl_end %}
{% if ban_list %}
{% include "users/aff_bans.html" with ban_list=ban_list %}
{% else %}
<p>
Aucun bannissement
</p>
{% endif %}
<h2>
Accès à titre gracieux :
</h2>
{% can_create Whitelist %}
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:add-whitelist' user.id %}"
><i
class=
"glyphicon glyphicon-flag"
></i>
Accorder un accès à titre gracieux
</a></h4>
{% acl_end %}
{% can_create Whitelist %}
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:add-whitelist' user
s
.id %}"
><i
class=
"glyphicon glyphicon-flag"
></i>
Accorder un accès à titre gracieux
</a></h4>
{% acl_end %}
{% if white_list %}
{% include "users/aff_whitelists.html" with white_list=white_list %}
{% else %}
...
...
users/views.py
View file @
20be7fdb
...
...
@@ -124,7 +124,7 @@ def password_change_action(u_form, user, request, req=False):
def
new_user
(
request
):
""" Vue de création d'un nouvel utilisateur,
envoie un mail pour le mot de passe"""
user
=
AdherentForm
(
request
.
POST
or
None
)
user
=
AdherentForm
(
request
.
POST
or
None
,
user
=
request
.
user
)
if
user
.
is_valid
():
user
=
user
.
save
(
commit
=
False
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
...
...
@@ -146,7 +146,7 @@ def new_user(request):
def
new_club
(
request
):
""" Vue de création d'un nouveau club,
envoie un mail pour le mot de passe"""
club
=
ClubForm
(
request
.
POST
or
None
)
club
=
ClubForm
(
request
.
POST
or
None
,
user
=
request
.
user
)
if
club
.
is_valid
():
club
=
club
.
save
(
commit
=
False
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
...
...
@@ -803,7 +803,7 @@ def profil(request, users, userid):
request
,
'users/profil.html'
,
{
'user'
:
users
,
'user
s
'
:
users
,
'machines_list'
:
machines
,
'facture_list'
:
factures
,
'ban_list'
:
bans
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment