Commit 378701af authored by Julian Rother's avatar Julian Rother
Browse files

Use @mod_required to decide if navitem is public

parent 3259f87d
......@@ -22,6 +22,7 @@ if __name__ == '__main__':
config['DEBUG'] = True
config.from_pyfile('', silent=True)
app.jinja_env.globals['videoprefix'] = config['VIDEOPREFIX']
mod_endpoints = []
if config['DB_ENGINE'] == 'sqlite':
created = not os.path.exists(config['SQLITE_DB'])
......@@ -127,6 +128,7 @@ def ismod(*args):
app.jinja_env.globals['ismod'] = ismod
def mod_required(func):
def decorator(*args, **kwargs):
if not ismod():
......@@ -134,12 +136,15 @@ def mod_required(func):
return redirect(url_for('login', ref=request.url))
return func(*args, **kwargs)
return decorator
app.jinja_env.globals['navbar'] = []
def register_navbar(name, icon=None, visible=True):
def register_navbar(name, icon=None):
def wrapper(func):
app.jinja_env.globals['navbar'].append((func.__name__, name, icon, visible))
endpoint = func.__name__
app.jinja_env.globals['navbar'].append((endpoint, name, icon,
not endpoint in mod_endpoints))
return func
return wrapper
......@@ -297,7 +302,8 @@ def auth(): # For use with nginx auth_request
@register_navbar('Drehplan', 'calendar', visible=False)
@register_navbar('Drehplan', 'calendar')
def schedule():
return render_template('schedule.html')
Supports Markdown
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