Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
378701af
Commit
378701af
authored
Aug 29, 2016
by
Julian Rother
Browse files
Use @mod_required to decide if navitem is public
parent
3259f87d
Changes
1
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
378701af
...
...
@@ -22,6 +22,7 @@ if __name__ == '__main__':
config
[
'DEBUG'
]
=
True
config
.
from_pyfile
(
'config.py'
,
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
):
mod_endpoints
.
append
(
func
.
__name__
)
@
wraps
(
func
)
def
decorator
(
*
args
,
**
kwargs
):
if
not
ismod
():
...
...
@@ -134,12 +136,15 @@ def mod_required(func):
return
redirect
(
url_for
(
'login'
,
ref
=
request
.
url
))
else
:
return
func
(
*
args
,
**
kwargs
)
print
(
decorator
.
__name__
)
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
@
app
.
route
(
'/schedule'
)
@
register_navbar
(
'Drehplan'
,
'calendar'
,
visible
=
False
)
@
register_navbar
(
'Drehplan'
,
'calendar'
)
@
mod_required
def
schedule
():
return
render_template
(
'schedule.html'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment