mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-29 10:23:47 +00:00
Templates tags can_change class
This commit is contained in:
parent
f842856878
commit
9f7d994c4a
5 changed files with 11 additions and 12 deletions
|
@ -149,10 +149,10 @@ class Facture(FieldPermissionModelMixin, models.Model):
|
|||
else:
|
||||
return True, None
|
||||
|
||||
def can_change_control(self, user, *args, **kwargs):
|
||||
def can_change_control(user, *args, **kwargs):
|
||||
return user.has_perms(('tresorier',)), "Vous ne pouvez pas éditer le controle sans droit trésorier"
|
||||
|
||||
def can_change_pdf(self, user, *args, **kwargs):
|
||||
def can_change_pdf(user, *args, **kwargs):
|
||||
return user.has_perms(('tresorier',)), "Vous ne pouvez pas éditer une facture sans droit trésorier"
|
||||
|
||||
field_permissions = {
|
||||
|
|
|
@ -26,16 +26,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% load acl %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% can_create Facture %}
|
||||
{% can_change Facture pdf %}
|
||||
<a class="list-group-item list-group-item-success" href="{% url "cotisations:new-facture-pdf" %}">
|
||||
<i class="glyphicon glyphicon-plus"></i>
|
||||
Créer une facture
|
||||
</a>
|
||||
{% acl_end %}
|
||||
<a class="list-group-item list-group-item-warning" href="{% url "cotisations:control" %}">
|
||||
<i class="glyphicon glyphicon-eye-open"></i>
|
||||
Contrôler les factures
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% can_view_all Facture %}
|
||||
<a class="list-group-item list-group-item-info" href="{% url "cotisations:index" %}">
|
||||
<i class="glyphicon glyphicon-list"></i>
|
||||
|
|
|
@ -17,9 +17,6 @@ class FieldPermissionModelMixin:
|
|||
checks = self.field_permissions[field]
|
||||
if not isinstance(checks, (list, tuple)):
|
||||
checks = [checks]
|
||||
for i, perm in enumerate(checks):
|
||||
if callable(perm):
|
||||
checks[i] = partial(perm, field=field)
|
||||
|
||||
else:
|
||||
checks = []
|
||||
|
@ -45,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(self, user=user)
|
||||
result, reason = perm(user=user)
|
||||
if result is not None:
|
||||
return result
|
||||
else:
|
||||
|
|
|
@ -820,13 +820,13 @@ class User(FieldPermissionModelMixin, AbstractBaseUser):
|
|||
else:
|
||||
return False, u"Vous ne pouvez éditer un autre utilisateur que vous même"
|
||||
|
||||
def can_change_state(self, user_request, *args, **kwargs):
|
||||
def can_change_state(user_request, *args, **kwargs):
|
||||
return user_request.has_perms(('bureau',)), "Droit bureau requis pour changer l'état"
|
||||
|
||||
def can_change_shell(self, user_request, *args, **kwargs):
|
||||
return user_request.has_perms(('cableur',)), "Droit requis pour forcer le déménagement"
|
||||
def can_change_shell(user_request, *args, **kwargs):
|
||||
return user_request.has_perms(('cableur',)), "Droit requis pour changer le shell"
|
||||
|
||||
def can_change_force(self, user_request, *args, **kwargs):
|
||||
def can_change_force(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):
|
||||
|
|
|
@ -81,8 +81,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<i class="glyphicon glyphicon-trash"></i>
|
||||
Retirer un droit
|
||||
</a>
|
||||
{% can_change User state %}
|
||||
<a class="list-group-item list-group-item-danger" href="{% url "users:mass-archive" %}">
|
||||
<i class="glyphicon glyphicon-book"></i>
|
||||
Archiver en masse
|
||||
</a>
|
||||
{% acl_end %}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue