mirror of
https://github.com/haiwen/seahub.git
synced 2025-06-27 07:28:42 +00:00
20 lines
661 B
Python
20 lines
661 B
Python
# 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:
|
|
request.user.org = org._dict
|
|
return func(request, *args, **kwargs)
|
|
return HttpResponseRedirect(reverse('myhome'))
|
|
return _decorated
|