update oxjs params and setUrl, some more user functions
This commit is contained in:
parent
4d4d500e4c
commit
0c8906ffbd
5 changed files with 14 additions and 13 deletions
18
utils/decorators.py
Normal file
18
utils/decorators.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
|
||||
|
||||
def login_required_json(function=None):
|
||||
"""
|
||||
Decorator for views that checks that the user is logged in
|
||||
return json error if not logged in.
|
||||
"""
|
||||
actual_decorator = user_passes_test(
|
||||
lambda u: u.is_authenticated(),
|
||||
login_url='/json/login',
|
||||
)
|
||||
if function:
|
||||
return actual_decorator(function)
|
||||
return actual_decorator
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue