1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 01:41:39 +00:00

[share] share repo with 'admin' perm: modification

This commit is contained in:
llj
2017-08-30 17:59:14 +08:00
parent 160e0b3027
commit 33266638ef
11 changed files with 76 additions and 40 deletions

View File

@@ -898,7 +898,7 @@
<% if (user_perm == 'rw' && !repo_encrypted && can_generate_upload_link) { %>
<li class="tab"><a href="#dir-upload-link-share" class="a">{% trans "Upload Link" %}</a></li>
<% } %>
<% if (!is_virtual && is_repo_owner) { %> {# dir private share #}
<% if (!is_virtual && (is_repo_owner || is_admin)) { %> {# dir private share #}
<li class="tab"><a href="#dir-user-share" class="a">{% trans "Share to user" %}</a></li>
<li class="tab"><a href="#dir-group-share" class="a">{% trans "Share to group" %}</a></li>
<% } %>
@@ -1016,7 +1016,7 @@
</div>
<% } %>
<% if (!is_virtual && is_repo_owner) { %>
<% if (!is_virtual && (is_repo_owner || is_admin)) { %>
<% if (!repo_encrypted) { %>
<div id="dir-user-share" class="tabs-panel hide">
<% } else { %>
@@ -1039,7 +1039,9 @@
<select name="permission" class="share-permission-select w100">
<option value="rw" selected="selected">{% trans "Read-Write" %}</option>
<option value="r">{% trans "Read-Only" %}</option>
<% if (app.pageOptions.is_pro && dirent_path == '/') { %> {# only for repo #}
<option value="admin">{% trans "Admin" %}</option>
<% } %>
</select>
</td>
<td><input type="submit" value="{% trans "Submit" %}" class="submit" /></td>
@@ -1086,16 +1088,12 @@
<img src="<%= icon_url %>" title="<%= icon_title %>" alt="<%= icon_title %>" width="24" />
</td>
<td><a href="#shared-libs/lib/<%= id %>"><%- name %></a></td>
<% if (is_admin) { %>
<td class="alc">
<% if (app.pageOptions.is_pro && is_admin) { %>
<a href="#" class="sf2-icon-share sf2-x repo-share-btn op-icon vh" title="{% trans "Share" %}"></a>
<a href="#" class="sf2-icon-delete sf2-x unshare-btn op-icon vh" title="{% trans "Leave Share" %}"></a>
</td>
<% } else { %>
<td class="alc">
<a href="#" class="sf2-icon-delete sf2-x unshare-btn op-icon vh" title="{% trans "Leave Share" %}"></a>
</td>
<% } %>
<a href="#" class="sf2-icon-delete sf2-x unshare-btn op-icon vh" title="{% trans "Leave Share" %}"></a>
</td>
<td><%= size_formatted %></td>
<td><%= mtime_relative %></td>
<td><span title="<%- owner %>"><%- owner_nickname %></span></td>
@@ -1297,7 +1295,7 @@
<td>
<div class="perm">
<span>
<% if (is_admin) { %>
<% if (show_admin && is_admin) { %>
{% trans "Admin" %}
<% } else { %>
<% if (permission == 'rw') { %>
@@ -1310,6 +1308,7 @@
<a href="#" title="{% trans "Edit" %}" class="perm-edit-icon sf2-icon-edit op-icon vh"></a>
</div>
<select class="perm-toggle-select hide w100">
<% if (show_admin) { %>
<% if (is_admin) { %>
<option value="rw">{% trans "Read-Write" %}</option>
<option value="r">{% trans "Read-Only" %}</option>
@@ -1325,6 +1324,15 @@
<option value="admin">{% trans "Admin" %}</option>
<% } %>
<% } %>
<% } else { %>
<% if (permission == 'rw') { %>
<option value="rw" selected="selected">{% trans "Read-Write" %}</option>
<option value="r">{% trans "Read-Only" %}</option>
<% } else { %>
<option value="rw">{% trans "Read-Write" %}</option>
<option value="r" selected="selected">{% trans "Read-Only" %}</option>
<% } %>
<% } %>
</select>
</td>
<td>

View File

@@ -30,7 +30,7 @@ from seahub.forms import RepoRenameDirentForm
from seahub.options.models import UserOptions, CryptoOptionNotSetError
from seahub.notifications.models import UserNotification
from seahub.notifications.views import add_notice_from_info
from seahub.share.models import UploadLinkShare
from seahub.share.models import UploadLinkShare, ExtraSharePermission
from seahub.signals import upload_file_successful
from seahub.views import get_unencry_rw_repos_by_user, \
get_diff, check_folder_permission
@@ -50,6 +50,7 @@ from seahub.thumbnail.utils import get_thumbnail_src
from seahub.utils.file_types import IMAGE, VIDEO
from seahub.base.templatetags.seahub_tags import translate_seahub_time, \
email2nickname, tsstr_sec
from seahub.constants import PERMISSION_ADMIN
# Get an instance of a logger
logger = logging.getLogger(__name__)
@@ -309,6 +310,9 @@ def list_lib_dir(request, repo_id):
except Exception as e:
logger.error(e)
# for shared repo
result["is_admin"] = ExtraSharePermission.objects.get_user_permission(repo_id, username) == PERMISSION_ADMIN
result["is_virtual"] = repo.is_virtual
result["repo_name"] = repo.name
result["user_perm"] = user_perm

View File

@@ -27,6 +27,7 @@ define([
this.has_been_shared_out = data.has_been_shared_out;
this.dirent_more = data.dirent_more;
this.more_start = data.more_start;
this.is_admin = data.is_admin;
return data.dirent_list; // return the array
},

View File

@@ -16,8 +16,7 @@ define([
encrypted: false,
owner: "-",
owner_nickname: "-",
permission: "rw",
is_admin: false
permission: "rw"
},
parse: function(response) {

View File

@@ -824,6 +824,9 @@ define([
'dirent_path': path,
'obj_name': path == '/' ? dir.repo_name : path.substr(path.lastIndexOf('/') + 1)
};
if (app.pageOptions.is_pro) {
options.is_admin = dir.is_admin;
}
new ShareView(options);
},

View File

@@ -203,6 +203,10 @@ define([
'dirent_path': dirent_path,
'obj_name': obj_name
};
if (app.pageOptions.is_pro) {
options.is_admin = dir.is_admin;
}
new ShareView(options);
this.closeMenu();
return false;

View File

@@ -361,6 +361,10 @@ define([
'dirent_path': dirent_path,
'obj_name': obj_name
};
if (app.pageOptions.is_pro) {
options.is_admin = dir.is_admin;
}
new ShareView(options);
this._hideMenu();

View File

@@ -20,11 +20,17 @@ define([
this.repo_id = options.repo_id;
this.path = options.path;
// show info about 'is_admin'
this.show_admin = false;
if (app.pageOptions.is_pro && this.path == '/' && this.item_data.for_user) {
this.show_admin = true;
}
this.render();
},
render: function () {
this.$el.html(this.template(this.item_data));
this.$el.html(this.template($.extend({}, this.item_data, {'show_admin': this.show_admin})));
return this;
},

View File

@@ -4,7 +4,7 @@ define([
'backbone',
'common',
'app/collections/repos',
'app/views/shared-repo',
'app/views/shared-repo'
], function($, _, Backbone, Common, RepoCollection, SharedRepoView) {
'use strict';

View File

@@ -14,6 +14,8 @@ define([
initialize: function(options) {
this.is_repo_owner = options.is_repo_owner;
// for shared repo
this.is_admin = options.is_admin; // true or undefined
this.is_virtual = options.is_virtual;
this.user_perm = options.user_perm;
this.repo_id = options.repo_id;
@@ -44,7 +46,7 @@ define([
if (this.user_perm == 'rw' && !this.repo_encrypted && app.pageOptions.can_generate_upload_link) {
this.uploadLinkPanelInit();
}
if (!this.is_virtual && this.is_repo_owner) {
if (!this.is_virtual && (this.is_repo_owner || this.is_admin)) {
this.dirUserSharePanelInit();
this.dirGroupSharePanelInit();
@@ -66,12 +68,14 @@ define([
.replace('{placeholder}', '<span class="op-target ellipsis ellipsis-op-target" title="' + Common.HTMLescape(this.obj_name) + '">' + Common.HTMLescape(this.obj_name) + '</span>'),
is_dir: this.is_dir,
is_repo_owner: this.is_repo_owner,
is_admin: this.is_admin,
is_virtual: this.is_virtual,
user_perm: this.user_perm,
repo_id: this.repo_id,
can_generate_share_link: app.pageOptions.can_generate_share_link,
can_generate_upload_link: app.pageOptions.can_generate_upload_link,
repo_encrypted: this.repo_encrypted
repo_encrypted: this.repo_encrypted,
dirent_path: this.dirent_path
}));
return this;
@@ -576,8 +580,8 @@ define([
"user_email": item.user_info.name,
"user_name": item.user_info.nickname,
"permission": item.permission,
'for_user': true,
'is_admin': item.is_admin
'is_admin': item.is_admin,
'for_user': true
}
});
$add_item.after(new_item.el);
@@ -757,15 +761,15 @@ define([
"user_email": item.user_info.name,
"user_name": item.user_info.nickname,
"permission": item.permission,
'for_user': true,
'is_admin': item.is_admin
'is_admin': item.is_admin,
'for_user': true
}
});
$add_item.after(new_item.el);
});
emails_input.select2("val", "");
$('option', $perm).removeAttr('selected');
$('[value="rw"]', $perm).attr('selected', 'selected');
$('[value="rw"]', $perm).nextAll().removeAttr('selected');
$error.addClass('hide');
}
if (data.failed.length > 0) {

View File

@@ -4,7 +4,7 @@ define([
'backbone',
'common',
'app/views/widgets/hl-item-view',
'app/views/share',
'app/views/share'
], function($, _, Backbone, Common, HLItemView, ShareView) {
'use strict';
@@ -16,7 +16,7 @@ define([
events: {
'click .unshare-btn': 'removeShare',
'click .repo-share-btn': 'share',
'click .repo-share-btn': 'share'
},
initialize: function() {
@@ -25,7 +25,9 @@ define([
share: function() {
var options = {
'is_repo_owner': true,
'is_repo_owner': false,
'is_admin': true, // only for shared repo
'is_virtual': false,
'user_perm': 'rw',
'repo_id': this.model.get('id'),
'repo_encrypted': this.model.get('encrypted'),
@@ -33,6 +35,7 @@ define([
'dirent_path': '/',
'obj_name': this.model.get('name')
};
new ShareView(options);
return false;
},