Commit d6564543 authored by LEVY-FALK Hugo's avatar LEVY-FALK Hugo Committed by root


parent 460bfad5
......@@ -105,10 +105,8 @@ def can_edit(model, *field_list):
def can_change(model, *field_list):
"""Decorator to check if an user can edit a field of a model.
It assumes that a valid user exists in the request and that the model has a
method can_create(user) which returns true if the user can create this kind
of models.
"""Decorator to check if an user can edit a field of a model class.
Difference with can_edit : take a class and not an instance
def decorator(view):
def wrapper(request, *args, **kwargs):
......@@ -246,6 +244,21 @@ def can_view_app(app_name):
return decorator
def can_edit_history(view):
"""Decorator to check if an user can edit history."""
def wrapper(request, *args, **kwargs):
if request.user.has_perms(('admin',)):
return view(request, *args, **kwargs)
"Vous ne pouvez pas éditer l'historique."
return redirect(reverse('users:profil',
return wrapper
def all_adherent(search_time=DT_NOW):
""" Fonction renvoyant tous les users adherents. Optimisee pour n'est
qu'une seule requete sql
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