mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-09 19:07:40 +00:00
Update function name and error msg
This commit is contained in:
parent
a8bf96d2e2
commit
df1e082e8c
@ -71,7 +71,7 @@ from seahub.utils import gen_file_get_url, gen_token, gen_file_upload_url, \
|
|||||||
gen_block_get_url, get_file_type_and_ext, HAS_FILE_SEARCH, \
|
gen_block_get_url, get_file_type_and_ext, HAS_FILE_SEARCH, \
|
||||||
gen_file_share_link, gen_dir_share_link, is_org_context, gen_shared_link, \
|
gen_file_share_link, gen_dir_share_link, is_org_context, gen_shared_link, \
|
||||||
get_org_user_events, calculate_repos_last_modify, send_perm_audit_msg, \
|
get_org_user_events, calculate_repos_last_modify, send_perm_audit_msg, \
|
||||||
gen_shared_upload_link, convert_cmmt_desc_link, enable_org_repo_creation
|
gen_shared_upload_link, convert_cmmt_desc_link, is_org_repo_creation_allowed
|
||||||
from seahub.utils.repo import get_sub_repo_abbrev_origin_path
|
from seahub.utils.repo import get_sub_repo_abbrev_origin_path
|
||||||
from seahub.utils.star import star_file, unstar_file
|
from seahub.utils.star import star_file, unstar_file
|
||||||
from seahub.utils.file_types import IMAGE, DOCUMENT
|
from seahub.utils.file_types import IMAGE, DOCUMENT
|
||||||
@ -1076,11 +1076,11 @@ class RepoPublic(APIView):
|
|||||||
"""
|
"""
|
||||||
repo = get_repo(repo_id)
|
repo = get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
|
return api_error(status.HTTP_404_NOT_FOUND, 'Library %s not found.' % repo_id)
|
||||||
|
|
||||||
if not enable_org_repo_creation(request):
|
if not is_org_repo_creation_allowed(request):
|
||||||
return api_error(status.HTTP_403_FORBIDDEN,
|
return api_error(status.HTTP_403_FORBIDDEN,
|
||||||
'Failed to share library to public: permission denied.')
|
'Permission denied.')
|
||||||
|
|
||||||
if check_permission(repo_id, request.user.username) != 'rw':
|
if check_permission(repo_id, request.user.username) != 'rw':
|
||||||
return api_error(status.HTTP_403_FORBIDDEN,
|
return api_error(status.HTTP_403_FORBIDDEN,
|
||||||
@ -3214,7 +3214,7 @@ class SharedRepo(APIView):
|
|||||||
|
|
||||||
elif share_type == 'public':
|
elif share_type == 'public':
|
||||||
if not CLOUD_MODE:
|
if not CLOUD_MODE:
|
||||||
if not enable_org_repo_creation(request):
|
if not is_org_repo_creation_allowed(request):
|
||||||
return api_error(status.HTTP_403_FORBIDDEN,
|
return api_error(status.HTTP_403_FORBIDDEN,
|
||||||
'Failed to share library to public: permission denied.')
|
'Failed to share library to public: permission denied.')
|
||||||
|
|
||||||
|
@ -1312,8 +1312,8 @@ def within_time_range(d1, d2, maxdiff_seconds):
|
|||||||
diff = (delta.microseconds + (delta.seconds + delta.days*24*3600) * 1e6) / 1e6
|
diff = (delta.microseconds + (delta.seconds + delta.days*24*3600) * 1e6) / 1e6
|
||||||
return diff < maxdiff_seconds
|
return diff < maxdiff_seconds
|
||||||
|
|
||||||
def enable_org_repo_creation(request):
|
def is_org_repo_creation_allowed(request):
|
||||||
"""Whether or not enable organization library.
|
"""Whether or not allow a user create organization library.
|
||||||
"""
|
"""
|
||||||
if request.user.is_staff:
|
if request.user.is_staff:
|
||||||
return True
|
return True
|
||||||
|
@ -54,7 +54,7 @@ from seahub.utils import render_permission_error, render_error, list_to_string,
|
|||||||
TRAFFIC_STATS_ENABLED, get_user_traffic_stat, new_merge_with_no_conflict, \
|
TRAFFIC_STATS_ENABLED, get_user_traffic_stat, new_merge_with_no_conflict, \
|
||||||
user_traffic_over_limit, send_perm_audit_msg, get_origin_repo_info, \
|
user_traffic_over_limit, send_perm_audit_msg, get_origin_repo_info, \
|
||||||
get_max_upload_file_size, is_pro_version, FILE_AUDIT_ENABLED, \
|
get_max_upload_file_size, is_pro_version, FILE_AUDIT_ENABLED, \
|
||||||
enable_org_repo_creation
|
is_org_repo_creation_allowed
|
||||||
from seahub.utils.paginator import get_page_range
|
from seahub.utils.paginator import get_page_range
|
||||||
from seahub.utils.star import get_dir_starred_files
|
from seahub.utils.star import get_dir_starred_files
|
||||||
from seahub.utils.timeutils import utc_to_local
|
from seahub.utils.timeutils import utc_to_local
|
||||||
@ -1268,7 +1268,7 @@ def libraries(request):
|
|||||||
UserOptions.objects.disable_user_guide(username)
|
UserOptions.objects.disable_user_guide(username)
|
||||||
|
|
||||||
folder_perm_enabled = True if is_pro_version() and ENABLE_FOLDER_PERM else False
|
folder_perm_enabled = True if is_pro_version() and ENABLE_FOLDER_PERM else False
|
||||||
can_add_pub_repo = True if enable_org_repo_creation(request) else False
|
can_add_pub_repo = True if is_org_repo_creation_allowed(request) else False
|
||||||
|
|
||||||
return render_to_response('libraries.html', {
|
return render_to_response('libraries.html', {
|
||||||
"allow_public_share": allow_public_share,
|
"allow_public_share": allow_public_share,
|
||||||
|
@ -67,4 +67,4 @@ class RepoPublicTest(BaseTestCase):
|
|||||||
resp = self.client.post(self.user_repo_url)
|
resp = self.client.post(self.user_repo_url)
|
||||||
self.assertEqual(403, resp.status_code)
|
self.assertEqual(403, resp.status_code)
|
||||||
json_resp = json.loads(resp.content)
|
json_resp = json.loads(resp.content)
|
||||||
assert json_resp['error_msg'] == 'Failed to share library to public: permission denied.'
|
assert json_resp['error_msg'] == 'Permission denied.'
|
||||||
|
Loading…
Reference in New Issue
Block a user