diff --git a/seahub/settings.py b/seahub/settings.py index bee5dd00cb..77b07d19d2 100644 --- a/seahub/settings.py +++ b/seahub/settings.py @@ -267,6 +267,11 @@ FORCE_SERVER_CRYPTO = True # Enable or disable repo history setting ENABLE_REPO_HISTORY_SETTING = True +# Enable or disable org repo creation by user +ENABLE_USER_CREATE_ORG_REPO = True + +DISABLE_SYNC_WITH_ANY_FOLDER = False + # File preview FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024 OFFICE_PREVIEW_MAX_SIZE = 2 * 1024 * 1024 @@ -613,13 +618,13 @@ INNER_FILE_SERVER_ROOT = 'http://127.0.0.1:' + FILE_SERVER_PORT CONSTANCE_CONFIG = { 'SERVICE_URL': (SERVICE_URL,''), 'FILE_SERVER_ROOT': (FILE_SERVER_ROOT,''), - 'DISABLE_SYNC_WITH_ANY_FOLDER': (False,''), + 'DISABLE_SYNC_WITH_ANY_FOLDER': (DISABLE_SYNC_WITH_ANY_FOLDER,''), 'ENABLE_SIGNUP': (ENABLE_SIGNUP,''), 'ACTIVATE_AFTER_REGISTRATION': (ACTIVATE_AFTER_REGISTRATION,''), 'REGISTRATION_SEND_MAIL': (REGISTRATION_SEND_MAIL ,''), 'LOGIN_REMEMBER_DAYS': (LOGIN_REMEMBER_DAYS,''), - 'ENABLE_ORGANIZATION_LIBRARY': (True, ''), + 'ENABLE_USER_CREATE_ORG_REPO': (ENABLE_USER_CREATE_ORG_REPO, ''), 'ENABLE_ENCRYPTED_LIBRARY': (ENABLE_ENCRYPTED_LIBRARY,''), 'REPO_PASSWORD_MIN_LENGTH': (REPO_PASSWORD_MIN_LENGTH,''), diff --git a/seahub/templates/sysadmin/settings.html b/seahub/templates/sysadmin/settings.html index fdc82ef9e2..3e5e4040e3 100644 --- a/seahub/templates/sysadmin/settings.html +++ b/seahub/templates/sysadmin/settings.html @@ -69,10 +69,6 @@ {% include "snippets/web_settings_form.html" %} {% endwith %} - {% with type="checkbox" setting_display_name="organization library" help_tip="Allow user to add organization library. If unchecked, only system admin can add library." setting_name="ENABLE_ORGANIZATION_LIBRARY" setting_val=config_dict.ENABLE_ORGANIZATION_LIBRARY %} - {% include "snippets/web_settings_form.html" %} - {% endwith %} - {% with type="input" setting_display_name="library password minimum length" help_tip="The least number of characters an encrypted library password should include." setting_name="REPO_PASSWORD_MIN_LENGTH" setting_val=config_dict.REPO_PASSWORD_MIN_LENGTH %} {% include "snippets/web_settings_form.html" %} {% endwith %} @@ -83,6 +79,12 @@ {% endwith %} +
+ {% with type="checkbox" setting_display_name="ENABLE_USER_CREATE_ORG_REPO" help_tip="Allow user to add organization library. If unchecked, only system admin can add library." setting_name="ENABLE_USER_CREATE_ORG_REPO" setting_val=config_dict.ENABLE_USER_CREATE_ORG_REPO %} + {% include "snippets/web_settings_form.html" %} + {% endwith %} +
+

Sync

diff --git a/seahub/utils/__init__.py b/seahub/utils/__init__.py index f110fbdf65..34b9f2b3f8 100644 --- a/seahub/utils/__init__.py +++ b/seahub/utils/__init__.py @@ -1318,4 +1318,4 @@ def is_org_repo_creation_allowed(request): if request.user.is_staff: return True else: - return config.ENABLE_ORGANIZATION_LIBRARY + return config.ENABLE_USER_CREATE_ORG_REPO diff --git a/seahub/views/sysadmin.py b/seahub/views/sysadmin.py index 7c4741a946..da52201427 100644 --- a/seahub/views/sysadmin.py +++ b/seahub/views/sysadmin.py @@ -2150,7 +2150,7 @@ def sys_settings(request): 'ENABLE_REPO_HISTORY_SETTING', 'USER_STRONG_PASSWORD_REQUIRED', 'ENABLE_ENCRYPTED_LIBRARY', 'USER_PASSWORD_MIN_LENGTH', 'USER_PASSWORD_STRENGTH_LEVEL', 'SHARE_LINK_PASSWORD_MIN_LENGTH', - 'ENABLE_ORGANIZATION_LIBRARY' + 'ENABLE_USER_CREATE_ORG_REPO' ) STRING_WEB_SETTINGS = ('SERVICE_URL', 'FILE_SERVER_ROOT',) diff --git a/tests/api/test_public_repo.py b/tests/api/test_public_repo.py index 9b73a32bf2..a1732718ec 100644 --- a/tests/api/test_public_repo.py +++ b/tests/api/test_public_repo.py @@ -14,7 +14,7 @@ class RepoPublicTest(BaseTestCase): self.url = '/api2/repos/%s/public/' % self.repo_id self.user_repo_url = '/api2/repos/%s/public/' % self.repo.id - config.ENABLE_ORGANIZATION_LIBRARY = 1 + config.ENABLE_USER_CREATE_ORG_REPO = 1 def tearDown(self): self.remove_repo(self.repo_id) @@ -46,9 +46,9 @@ class RepoPublicTest(BaseTestCase): assert json_resp['success'] is True def test_admin_can_set_pub_repo_when_setting_disalbed(self): - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True - config.ENABLE_ORGANIZATION_LIBRARY = False - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True + config.ENABLE_USER_CREATE_ORG_REPO = False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False self.login_as(self.admin) @@ -58,9 +58,9 @@ class RepoPublicTest(BaseTestCase): assert json_resp['success'] is True def test_user_can_not_set_pub_repo_when_setting_disalbed(self): - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True - config.ENABLE_ORGANIZATION_LIBRARY = False - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True + config.ENABLE_USER_CREATE_ORG_REPO = False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False self.login_as(self.user) diff --git a/tests/api/test_shared_repo.py b/tests/api/test_shared_repo.py index a70b159a1e..ce2645745f 100644 --- a/tests/api/test_shared_repo.py +++ b/tests/api/test_shared_repo.py @@ -12,7 +12,7 @@ class SharedRepoTest(BaseTestCase): username=self.admin.username, passwd=None) self.shared_repo_url = '/api2/shared-repos/%s/?share_type=public&permission=rw' - config.ENABLE_ORGANIZATION_LIBRARY = 1 + config.ENABLE_USER_CREATE_ORG_REPO = 1 def tearDown(self): self.remove_repo(self.repo_id) @@ -34,9 +34,9 @@ class SharedRepoTest(BaseTestCase): assert "success" in resp.content def test_admin_can_set_pub_repo_when_setting_disalbed(self): - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True - config.ENABLE_ORGANIZATION_LIBRARY = False - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True + config.ENABLE_USER_CREATE_ORG_REPO = False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False self.login_as(self.admin) @@ -45,9 +45,9 @@ class SharedRepoTest(BaseTestCase): assert "success" in resp.content def test_user_can_not_set_pub_repo_when_setting_disalbed(self): - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True - config.ENABLE_ORGANIZATION_LIBRARY = False - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True + config.ENABLE_USER_CREATE_ORG_REPO = False + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False self.login_as(self.user) diff --git a/tests/seahub/views/init/test_libraries.py b/tests/seahub/views/init/test_libraries.py index f575956c4c..3a67cb966f 100644 --- a/tests/seahub/views/init/test_libraries.py +++ b/tests/seahub/views/init/test_libraries.py @@ -30,15 +30,15 @@ class LibrariesTest(BaseTestCase): # user self.login_as(self.user) - config.ENABLE_ORGANIZATION_LIBRARY = 1 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True + config.ENABLE_USER_CREATE_ORG_REPO = 1 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True resp = self.client.get(self.url) self.assertEqual(200, resp.status_code) assert resp.context['can_add_pub_repo'] is True - config.ENABLE_ORGANIZATION_LIBRARY = 0 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + config.ENABLE_USER_CREATE_ORG_REPO = 0 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False resp = self.client.get(self.url) self.assertEqual(200, resp.status_code) @@ -50,15 +50,15 @@ class LibrariesTest(BaseTestCase): # admin self.login_as(self.admin) - config.ENABLE_ORGANIZATION_LIBRARY = 1 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True + config.ENABLE_USER_CREATE_ORG_REPO = 1 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True resp = self.client.get(self.url) self.assertEqual(200, resp.status_code) assert resp.context['can_add_pub_repo'] is True - config.ENABLE_ORGANIZATION_LIBRARY = 0 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + config.ENABLE_USER_CREATE_ORG_REPO = 0 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False resp = self.client.get(self.url) self.assertEqual(200, resp.status_code) diff --git a/tests/seahub/views/test_libraries.py b/tests/seahub/views/test_libraries.py index 675fd2f3f2..555c0b49ae 100644 --- a/tests/seahub/views/test_libraries.py +++ b/tests/seahub/views/test_libraries.py @@ -11,15 +11,15 @@ class LibrariesTests(BaseTestCase): # user self.login_as(self.user) - config.ENABLE_ORGANIZATION_LIBRARY = 1 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True + config.ENABLE_USER_CREATE_ORG_REPO = 1 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True resp = self.client.get(self.url) self.assertEqual(200, resp.status_code) assert resp.context['can_add_pub_repo'] is True - config.ENABLE_ORGANIZATION_LIBRARY = 0 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + config.ENABLE_USER_CREATE_ORG_REPO = 0 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False resp = self.client.get(self.url) self.assertEqual(200, resp.status_code) @@ -31,15 +31,15 @@ class LibrariesTests(BaseTestCase): # admin self.login_as(self.admin) - config.ENABLE_ORGANIZATION_LIBRARY = 1 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True + config.ENABLE_USER_CREATE_ORG_REPO = 1 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True resp = self.client.get(self.url) self.assertEqual(200, resp.status_code) assert resp.context['can_add_pub_repo'] is True - config.ENABLE_ORGANIZATION_LIBRARY = 0 - assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False + config.ENABLE_USER_CREATE_ORG_REPO = 0 + assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False resp = self.client.get(self.url) self.assertEqual(200, resp.status_code)