def perm_required(func):
""" Check if user can do actions
"""
@wraps(func)
def check_perm(*args, **kwargs):
if 'report' in kwargs:
GeneralController.check_perms(
method=request.method,
user=g.user,
report=kwargs['report']
)
if 'ticket' in kwargs:
GeneralController.check_perms(
method=request.method,
user=g.user,
ticket=kwargs['ticket']
)
if 'defendant' in kwargs and request.method != 'GET':
GeneralController.check_perms(
method=request.method,
user=g.user,
defendant=kwargs['defendant']
)
return func(*args, **kwargs)
return check_perm
评论列表
文章目录