1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 23:34:45 +00:00
Files
seahub/organizations/decorators.py

20 lines
661 B
Python
Raw Normal View History

2012-08-03 16:37:36 +08:00
# encoding: utf-8
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
from seaserv import get_user_current_org
def org_staff_required(func):
"""
Decorator for views that checks the user is org staff.
"""
def _decorated(request, *args, **kwargs):
user = request.user.username
url_prefix = kwargs.get('url_prefix', '')
org = get_user_current_org(user, url_prefix)
if org and org.is_staff:
2012-08-31 17:28:50 +08:00
request.user.org = org._dict
2012-08-03 16:37:36 +08:00
return func(request, *args, **kwargs)
return HttpResponseRedirect(reverse('myhome'))
return _decorated