move in preparation for virtualenv setup
This commit is contained in:
parent
ac65635b69
commit
973b3600af
33 changed files with 0 additions and 0 deletions
0
oxdb/utils/__init__.py
Normal file
0
oxdb/utils/__init__.py
Normal file
18
oxdb/utils/decorators.py
Normal file
18
oxdb/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
|
||||
|
||||
14
oxdb/utils/shortcuts.py
Normal file
14
oxdb/utils/shortcuts.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.utils import simplejson
|
||||
from django.conf import settings
|
||||
|
||||
def render_to_json_response(dictionary, content_type="text/json"):
|
||||
indent=None
|
||||
if settings.DEBUG:
|
||||
content_type = "text/javascript"
|
||||
indent = 2
|
||||
return HttpResponse(simplejson.dumps(dictionary, indent=indent), content_type=content_type)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue