Commit dd4a695d authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Gestion de la page des logs avec has_perm

parent 68e824e6
......@@ -35,5 +35,5 @@ def can_view(user):
A couple (allowed, msg) where allowed is a boolean which is True if
viewing is granted and msg is a message (can be None).
can = user.has_module_perms('logs')
can = user.has_module_perms('admin')
return can, None if can else "Vous ne pouvez pas voir cette application."
......@@ -408,7 +408,7 @@ def stats_users(request):
'Droits': User.objects.annotate(
'Etablissement': {
......@@ -222,7 +222,7 @@ def can_view_app(app_name):
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',)):
if request.user.has_perm('admin.change_logentry'):
return view(request, *args, **kwargs)
......@@ -183,9 +183,9 @@ def get_callback(tag_name, obj=None):
if tag_name == 'cannot_view_app':
return acl_fct(sys.modules[obj].can_view, True)
if tag_name == 'can_edit_history':
return acl_fct(lambda user:(user.has_perms(('admin',)),None),False)
return acl_fct(lambda user:(user.has_perm('admin.change_logentry'),None),False)
if tag_name == 'cannot_edit_history':
return acl_fct(lambda user:(user.has_perms(('admin',)),None),True)
return acl_fct(lambda user:(user.has_perm('admin.change_logentry'),None),True)
raise template.TemplateSyntaxError(
"%r tag is not a valid can_xxx tag" % tag_name
......@@ -68,7 +68,8 @@ class Migration(migrations.Migration):
'cableur': ['view_article',
'cableur': ['add_logentry',
......@@ -185,7 +186,10 @@ class Migration(migrations.Migration):
'admin': ['add_assooption',
'admin': ['add_logentry',
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