Commit 9f7d994c authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Templates tags can_change class

parent f8428568
......@@ -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 %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment