Move route_show_if into decorators

Also removes unused route_hide_if
This commit is contained in:
Joseph Schorr 2017-07-20 11:07:31 -04:00
parent ed3ba07830
commit 17f3de811e
9 changed files with 24 additions and 46 deletions

View file

@ -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