1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-27 15:37:43 +00:00
seahub/organizations/decorators.py

20 lines
661 B
Python
Raw Normal View History

2012-08-03 08:37:36 +00: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 09:28:50 +00:00
request.user.org = org._dict
2012-08-03 08:37:36 +00:00
return func(request, *args, **kwargs)
return HttpResponseRedirect(reverse('myhome'))
return _decorated