1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 15:26:19 +00:00

add MULTI_TENANCY check when admin transfer a repo

This commit is contained in:
lian
2016-08-20 11:12:15 +08:00
parent b66e1b8364
commit 0ed0919599
2 changed files with 30 additions and 26 deletions

View File

@@ -9,7 +9,6 @@ from rest_framework import status
from django.template.defaultfilters import filesizeformat from django.template.defaultfilters import filesizeformat
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
import seaserv
from seaserv import ccnet_api, seafile_api, seafserv_threaded_rpc from seaserv import ccnet_api, seafile_api, seafserv_threaded_rpc
from seahub.views import get_system_default_repo_id from seahub.views import get_system_default_repo_id
@@ -18,6 +17,11 @@ from seahub.api2.authentication import TokenAuthentication
from seahub.api2.throttling import UserRateThrottle from seahub.api2.throttling import UserRateThrottle
from seahub.api2.utils import api_error from seahub.api2.utils import api_error
try:
from seahub.settings import MULTI_TENANCY
except ImportError:
MULTI_TENANCY = False
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def get_repo_info(repo): def get_repo_info(repo):
@@ -170,6 +174,7 @@ class AdminLibrary(APIView):
error_msg = 'User %s not found.' % new_owner error_msg = 'User %s not found.' % new_owner
return api_error(status.HTTP_404_NOT_FOUND, error_msg) return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if MULTI_TENANCY:
try: try:
if seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id) > 0: if seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id) > 0:
error_msg = 'Can not transfer organization library.' error_msg = 'Can not transfer organization library.'
@@ -225,8 +230,7 @@ class AdminLibrary(APIView):
if repo_id != pub_repo.id: if repo_id != pub_repo.id:
continue continue
seaserv.seafserv_threaded_rpc.set_inner_pub_repo( seafile_api.add_inner_pub_repo(repo_id, pub_repo.permission)
repo_id, pub_repo.permission)
break break

View File

@@ -1523,6 +1523,7 @@ def sys_repo_transfer(request):
messages.error(request, _(u'Failed to transfer, user %s not found') % new_owner) messages.error(request, _(u'Failed to transfer, user %s not found') % new_owner)
return HttpResponseRedirect(next) return HttpResponseRedirect(next)
if MULTI_TENANCY:
try: try:
if seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id) > 0: if seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id) > 0:
messages.error(request, _(u'Can not transfer organization library')) messages.error(request, _(u'Can not transfer organization library'))
@@ -1578,8 +1579,7 @@ def sys_repo_transfer(request):
if repo_id != pub_repo.id: if repo_id != pub_repo.id:
continue continue
seaserv.seafserv_threaded_rpc.set_inner_pub_repo( seafile_api.add_inner_pub_repo(repo_id, pub_repo.permission)
repo_id, pub_repo.permission)
break break