diff --git a/seahub/templates/snippets/file_share_popup.html b/seahub/templates/snippets/file_share_popup.html index 06cece6784..47f147257d 100644 --- a/seahub/templates/snippets/file_share_popup.html +++ b/seahub/templates/snippets/file_share_popup.html @@ -3,13 +3,17 @@

{% trans 'Share %(name)s' %}

+ + {% if is_repo_owner %}
{% csrf_token %} @@ -20,6 +24,7 @@
+ {% endif %} - {% if ENABLE_SUB_LIBRARY and not repo.is_virtual %} + {% if ENABLE_SUB_LIBRARY and not repo.is_virtual and is_repo_owner %}

{% trans "You need to create a sub-library from this directory to let others sync it." %}

diff --git a/seahub/templates/snippets/shared_link_js.html b/seahub/templates/snippets/shared_link_js.html index 4e5a6a7206..2f8ad245dd 100644 --- a/seahub/templates/snippets/shared_link_js.html +++ b/seahub/templates/snippets/shared_link_js.html @@ -87,7 +87,15 @@ function showSharePopup(op, name, aj_url, type, cur_path) { }, 10); }); }, - error: ajaxErrorHandler + error: function(xhr, textStatus, errorThrown) { + var err; + if (xhr.responseText) { + err = jQuery.parseJSON(xhr.responseText).error; + } else { + err = "{% trans "Failed. Please check the network." %}"; + } + $('#syncable-share').append('

' + err + '

'); + } }); } diff --git a/seahub/views/file.py b/seahub/views/file.py index 82c49fc5c7..3ddd4e6d54 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -311,6 +311,9 @@ def view_file(request, repo_id): obj_id, path) if not user_perm: return render_permission_error(request, _(u'Unable to view file')) + + # check if the user is the owner or not, for 'private share' + is_repo_owner = seafile_api.is_repo_owner(username, repo.id) # get file type and extension filetype, fileext = get_file_type_and_ext(u_filename) @@ -412,6 +415,7 @@ def view_file(request, repo_id): search_repo_id = repo.id return render_to_response(template, { 'repo': repo, + 'is_repo_owner': is_repo_owner, 'obj_id': obj_id, 'filename': u_filename, 'path': path,