mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 08:23:46 +00:00
Gestion de la page des logs avec has_perm
This commit is contained in:
parent
f9b80c5866
commit
54d69790b7
5 changed files with 11 additions and 7 deletions
|
@ -35,5 +35,5 @@ def can_view(user):
|
||||||
A couple (allowed, msg) where allowed is a boolean which is True if
|
A couple (allowed, msg) where allowed is a boolean which is True if
|
||||||
viewing is granted and msg is a message (can be None).
|
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."
|
return can, None if can else "Vous ne pouvez pas voir cette application."
|
||||||
|
|
|
@ -408,7 +408,7 @@ def stats_users(request):
|
||||||
num=Count('whitelist')
|
num=Count('whitelist')
|
||||||
).order_by('-num')[:10],
|
).order_by('-num')[:10],
|
||||||
'Droits': User.objects.annotate(
|
'Droits': User.objects.annotate(
|
||||||
num=Count('right')
|
num=Count('groups')
|
||||||
).order_by('-num')[:10],
|
).order_by('-num')[:10],
|
||||||
},
|
},
|
||||||
'Etablissement': {
|
'Etablissement': {
|
||||||
|
|
|
@ -222,7 +222,7 @@ def can_view_app(app_name):
|
||||||
def can_edit_history(view):
|
def can_edit_history(view):
|
||||||
"""Decorator to check if an user can edit history."""
|
"""Decorator to check if an user can edit history."""
|
||||||
def wrapper(request, *args, **kwargs):
|
def wrapper(request, *args, **kwargs):
|
||||||
if request.user.has_perms(('admin',)):
|
if request.user.has_perm('admin.change_logentry'):
|
||||||
return view(request, *args, **kwargs)
|
return view(request, *args, **kwargs)
|
||||||
messages.error(
|
messages.error(
|
||||||
request,
|
request,
|
||||||
|
|
|
@ -183,9 +183,9 @@ def get_callback(tag_name, obj=None):
|
||||||
if tag_name == 'cannot_view_app':
|
if tag_name == 'cannot_view_app':
|
||||||
return acl_fct(sys.modules[obj].can_view, True)
|
return acl_fct(sys.modules[obj].can_view, True)
|
||||||
if tag_name == 'can_edit_history':
|
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':
|
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(
|
raise template.TemplateSyntaxError(
|
||||||
"%r tag is not a valid can_xxx tag" % tag_name
|
"%r tag is not a valid can_xxx tag" % tag_name
|
||||||
|
|
|
@ -68,7 +68,8 @@ class Migration(migrations.Migration):
|
||||||
'change_whitelist',
|
'change_whitelist',
|
||||||
'delete_whitelist',
|
'delete_whitelist',
|
||||||
'view_whitelist'],
|
'view_whitelist'],
|
||||||
'cableur': ['view_article',
|
'cableur': ['add_logentry',
|
||||||
|
'view_article',
|
||||||
'add_banque',
|
'add_banque',
|
||||||
'change_banque',
|
'change_banque',
|
||||||
'delete_banque',
|
'delete_banque',
|
||||||
|
@ -185,7 +186,10 @@ class Migration(migrations.Migration):
|
||||||
'change_vente',
|
'change_vente',
|
||||||
'delete_vente',
|
'delete_vente',
|
||||||
'view_vente'],
|
'view_vente'],
|
||||||
'admin': ['add_assooption',
|
'admin': ['add_logentry',
|
||||||
|
'change_logentry',
|
||||||
|
'delete_logentry',
|
||||||
|
'add_assooption',
|
||||||
'change_assooption',
|
'change_assooption',
|
||||||
'delete_assooption',
|
'delete_assooption',
|
||||||
'view_assooption',
|
'view_assooption',
|
||||||
|
|
Loading…
Reference in a new issue