mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 05:39:59 +00:00
[api2] Add DISABLE_SYNC_WITH_ANY_FOLDER config to server info
This commit is contained in:
@@ -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
|
||||
|
@@ -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'])
|
||||
|
Reference in New Issue
Block a user