mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-23 20:37:42 +00:00
Merge pull request #1022 from haiwen/5.0-settings
[settings] Update pub repo creation and sync with folder
This commit is contained in:
@@ -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,''),
|
||||
|
@@ -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 %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{% 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 %}
|
||||
</div>
|
||||
|
||||
<h4>Sync</h4>
|
||||
|
||||
<div>
|
||||
|
@@ -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
|
||||
|
@@ -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',)
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user