1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-31 22:57:47 +00:00

Update function name and error msg

This commit is contained in:
zhengxie 2016-01-26 10:38:19 +08:00
parent a8bf96d2e2
commit df1e082e8c
4 changed files with 10 additions and 10 deletions

View File

@ -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_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, \
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.star import star_file, unstar_file
from seahub.utils.file_types import IMAGE, DOCUMENT
@ -1076,11 +1076,11 @@ class RepoPublic(APIView):
"""
repo = get_repo(repo_id)
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,
'Failed to share library to public: permission denied.')
'Permission denied.')
if check_permission(repo_id, request.user.username) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
@ -3214,7 +3214,7 @@ class SharedRepo(APIView):
elif share_type == 'public':
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,
'Failed to share library to public: permission denied.')

View File

@ -1312,8 +1312,8 @@ def within_time_range(d1, d2, maxdiff_seconds):
diff = (delta.microseconds + (delta.seconds + delta.days*24*3600) * 1e6) / 1e6
return diff < maxdiff_seconds
def enable_org_repo_creation(request):
"""Whether or not enable organization library.
def is_org_repo_creation_allowed(request):
"""Whether or not allow a user create organization library.
"""
if request.user.is_staff:
return True

View File

@ -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, \
user_traffic_over_limit, send_perm_audit_msg, get_origin_repo_info, \
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.star import get_dir_starred_files
from seahub.utils.timeutils import utc_to_local
@ -1268,7 +1268,7 @@ def libraries(request):
UserOptions.objects.disable_user_guide(username)
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', {
"allow_public_share": allow_public_share,

View File

@ -67,4 +67,4 @@ class RepoPublicTest(BaseTestCase):
resp = self.client.post(self.user_repo_url)
self.assertEqual(403, resp.status_code)
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.'