8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 11:23:10 +00:00

Acl dans les modèles de users.

This commit is contained in:
LEVY-FALK Hugo 2017-12-28 00:10:30 +01:00 committed by root
parent 970fe94656
commit 75948450dd
8 changed files with 40 additions and 25 deletions

View file

@ -126,6 +126,7 @@ MODEL_NAME = {
'Room' : topologie.Room,
# users
'User' : users.User,
'Adherent' : users.Adherent,
'Club' : users.Club,
'ServiceUser' : users.ServiceUser,
'Right' : users.Right,

View file

@ -1077,7 +1077,7 @@ class Right(models.Model):
def can_create(user_request, *args, **kwargs):
"""Check if an user can create a Right object.
:param user_request: The user who wants to create a user object.
:param user_request: The user who wants to create an object.
:return: a message and a boolean which is True if the user can create.
"""
return user_request.has_perms(('bureau',)), u"Vous n'avez pas le droit de\

View file

@ -21,7 +21,7 @@ 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 acl %}
{% if ban_list.paginator %}
{% include "pagination.html" with list=ban_list %}
{% endif %}
@ -47,9 +47,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ ban.date_start }}</td>
<td>{{ ban.date_end }}</td>
<td class="text-right">
{% if is_bofh %}
{% can_edit ban %}
{% include 'buttons/edit.html' with href='users:edit-ban' id=ban.id %}
{% endif %}
{% acl_end %}
{% include 'buttons/history.html' with href='users:history' name='ban' id=ban.id %}
</td>
</tr>

View file

@ -21,7 +21,7 @@ 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 acl %}
<table class="table table-striped">
<thead>
<tr>
@ -33,7 +33,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<td>{{ school.name }}</td>
<td class="text-right">
{% can_edit school %}
{% include 'buttons/edit.html' with href='users:edit-school' id=school.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='users:history' name='school' id=school.id %}
</td>
</tr>

View file

@ -21,7 +21,7 @@ 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 acl %}
<table class="table table-striped">
<thead>
<tr>
@ -37,8 +37,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ serviceuser.access_group }}</td>
<td>{{ serviceuser.comment }}</td>
<td class="text-right">
{% can_delete serviceuser %}
{% include 'buttons/suppr.html' with href='users:del-serviceuser' id=serviceuser.id %}
{% acl_end %}
{% can_edit serviceuser %}
{% include 'buttons/edit.html' with href='users:edit-serviceuser' id=serviceuser.id %}
{% acl_end %}
{% include 'buttons/history.html' with href='users:history' name='serviceuser' id=serviceuser.id %}
</td>
</tr>

View file

@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if white_list.paginator %}
{% include "pagination.html" with list=white_list %}
{% endif %}
{% load acl %}
<table class="table table-striped">
<thead>
<tr>
@ -47,9 +47,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ whitelist.date_start }}</td>
<td>{{ whitelist.date_end }}</td>
<td class="text-right">
{% if is_cableur %}
{% can_edit whitelist %}
{% include 'buttons/edit.html' with href='users:edit-whitelist' id=whitelist.id %}
{% endif %}
{% acl_end %}
{% include 'buttons/history.html' with href='users:history' name='whitelist' id=whitelist.id %}
</td>
</tr>

View file

@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load bootstrap3 %}
{% load acl %}
{% block title %}Profil{% endblock %}
{% block content %}
@ -38,7 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="glyphicon glyphicon-lock"></i>
Changer le mot de passe
</a>
{% if is_bureau %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:state' user.id %}">
<i class="glyphicon glyphicon-flash"></i>
Changer le statut
@ -47,7 +46,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="glyphicon glyphicon-ok"></i>
Ajouter un droit
</a>
{% endif %}
<a class="btn btn-info btn-sm" role="button" href="{% url 'users:history' 'user' user.id %}">
<i class="glyphicon glyphicon-time"></i>
Historique
@ -189,21 +187,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<p>Aucune machine</p>
{% endif %}
<h2>Cotisations</h2>
{% if is_cableur %}<h4><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> {% 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>{% endif%}
<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>
{% if facture_list %}
{% include "cotisations/aff_cotisations.html" with facture_list=facture_list %}
{% else %}
<p>Aucune facture</p>
{% endif %}
<h2>Bannissements</h2>
{% if is_bofh %}<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>{% endif %}
{% 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 %}
{% 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>
{% if is_cableur %}<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>{% endif %}
{% 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 %}
{% if white_list %}
{% include "users/aff_whitelists.html" with white_list=white_list %}
{% else %}

View file

@ -22,49 +22,61 @@ 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 acl %}
{% block sidebar %}
{% if is_cableur %}
{% can_create Club %}
<a class="list-group-item list-group-item-success" href="{% url "users:new-club" %}">
<i class="glyphicon glyphicon-plus"></i>
Créer un club/association
</a>
{% endif %}
{% acl_end %}
{% can_create User %}
<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>
{% acl_end %}
<a class="list-group-item list-group-item-info" href="{% url "users:index-clubs" %}">
<i class="glyphicon glyphicon-list"></i>
Clubs et assos
</a>
{% if is_cableur %}
{% can_view_all Adherent %}
<a class="list-group-item list-group-item-info" href="{% url "users:index" %}">
<i class="glyphicon glyphicon-list"></i>
Adherents
</a>
{% acl_end %}
{% can_view_all Ban %}
<a class="list-group-item list-group-item-info" href="{% url "users:index-ban" %}">
<i class="glyphicon glyphicon-list"></i>
Bannissements
</a>
{% acl_end %}
{% can_view_all Whitelist %}
<a class="list-group-item list-group-item-info" href="{% url "users:index-white" %}">
<i class="glyphicon glyphicon-list"></i>
Accès à titre gracieux
</a>
{% acl_end %}
{% can_view_all School %}
<a class="list-group-item list-group-item-info" href="{% url "users:index-school" %}">
<i class="glyphicon glyphicon-list"></i>
Établissements
</a>
{% acl_end %}
{% can_view_all ListRight %}
<a class="list-group-item list-group-item-info" href="{% url "users:index-listright" %}">
<i class="glyphicon glyphicon-list"></i>
Droits
</a>
{% acl_end %}
{% can_view_all ServiceUser %}
<a class="list-group-item list-group-item-info" href="{% url "users:index-serviceusers" %}">
<i class="glyphicon glyphicon-list"></i>
Gérer les service users
</a>
{% if is_bureau %}
{% acl_end %}
<a class="list-group-item list-group-item-danger" href="{% url "users:del-right" %}">
<i class="glyphicon glyphicon-trash"></i>
Retirer un droit
@ -73,6 +85,4 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="glyphicon glyphicon-book"></i>
Archiver en masse
</a>
{% endif %}
{% endif %}
{% endblock %}