Move route_show_if into decorators
Also removes unused route_hide_if
This commit is contained in:
parent
ed3ba07830
commit
17f3de811e
9 changed files with 24 additions and 46 deletions
|
@ -38,3 +38,17 @@ def check_anon_protection(func):
|
|||
|
||||
abort(401)
|
||||
return wrapper
|
||||
|
||||
|
||||
def route_show_if(value):
|
||||
""" Adds/shows the decorated route if the given value is True. """
|
||||
def decorator(f):
|
||||
@wraps(f)
|
||||
def decorated_function(*args, **kwargs):
|
||||
if not value:
|
||||
abort(404)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
return decorated_function
|
||||
return decorator
|
||||
|
||||
|
|
Reference in a new issue