1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 13:50:07 +00:00

[api2] Add DISABLE_SYNC_WITH_ANY_FOLDER config to server info

This commit is contained in:
zhengxie
2015-06-25 16:08:14 +08:00
parent f33d756308
commit a037b9b638
2 changed files with 22 additions and 2 deletions

View File

@@ -3,6 +3,11 @@ from rest_framework.views import APIView
from seahub.api2.utils import json_response
from seahub import settings
from seahub.utils import HAS_OFFICE_CONVERTER, HAS_FILE_SEARCH
try:
from seahub.settings import DISABLE_SYNC_WITH_ANY_FOLDER
except ImportError:
DISABLE_SYNC_WITH_ANY_FOLDER = False
class ServerInfoView(APIView):
"""
@@ -25,6 +30,8 @@ class ServerInfoView(APIView):
if HAS_FILE_SEARCH:
features.append('file-search')
info['features'] = features
if DISABLE_SYNC_WITH_ANY_FOLDER:
features.append('disable-sync-with-any-folder')
info['features'] = features
return info

View File

@@ -1,9 +1,14 @@
import json
import unittest
import requests
from django.test import TestCase
from seahub import settings
from tests.api.apitestbase import ApiTestBase
from tests.api.urls import LIST_GROUP_AND_CONTACTS_URL, SERVER_INFO_URL
class MiscApiTest(ApiTestBase):
class MiscApiTest(ApiTestBase, TestCase):
def test_list_group_and_contacts(self):
res = self.get(LIST_GROUP_AND_CONTACTS_URL).json()
self.assertIsNotNone(res)
@@ -20,3 +25,11 @@ class MiscApiTest(ApiTestBase):
info = r.json()
self.assertTrue('version' in info)
self.assertTrue('seafile-basic' in info['features'])
self.assertFalse('disable-sync-with-any-folder' in info['features'])
def test_server_info_with_disable_sync(self):
settings.DISABLE_SYNC_WITH_ANY_FOLDER = True
resp = self.client.get('/api2/server-info/')
info = json.loads(resp.content)
self.assertTrue('disable-sync-with-any-folder' in info['features'])