1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 17:33:18 +00:00

modified 'group repo' & some improvement

This commit is contained in:
llj
2015-04-20 14:31:22 +08:00
committed by Daniel Pan
parent ed4447150d
commit b00d29c8e2
6 changed files with 32 additions and 21 deletions

View File

@@ -3136,6 +3136,8 @@ class GroupRepos(APIView):
else: else:
repos = seaserv.get_group_repos(group.id, username) repos = seaserv.get_group_repos(group.id, username)
group.is_staff = is_group_staff(group, request.user)
repos_json = [] repos_json = []
for r in repos: for r in repos:
repo = { repo = {
@@ -3149,11 +3151,12 @@ class GroupRepos(APIView):
"encrypted": r.encrypted, "encrypted": r.encrypted,
"permission": check_permission(r.id, username), "permission": check_permission(r.id, username),
"owner": r.owner, "owner": r.owner,
"owner_nickname": email2nickname(r.owner) "owner_nickname": email2nickname(r.owner),
"share_from_me": r.share_from_me,
} }
repos_json.append(repo) repos_json.append(repo)
return Response(repos_json) return Response({"is_staff":group.is_staff, "repos":repos_json})
class GroupRepo(APIView): class GroupRepo(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication) authentication_classes = (TokenAuthentication, SessionAuthentication)

View File

@@ -57,7 +57,7 @@
</td> </td>
<td><a href="#group/<%= group_id %>/lib/<%= id %>"><%- name %></a></td> <td><a href="#group/<%= group_id %>/lib/<%= id %>"><%- name %></a></td>
<td class="alc"> <td class="alc">
<% if (app.pageOptions.isGroupStaff) { %> <% if (is_staff || share_from_me) { %>
<img src="{{ MEDIA_URL }}img/delete-orange.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" /> <img src="{{ MEDIA_URL }}img/delete-orange.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
<% } %> <% } %>
</td> </td>

View File

@@ -18,15 +18,15 @@ define([
}, },
parse: function (data) { parse: function (data) {
this.repo_name = data.repo_name; this.repo_name = data.repo_name;
this.user_perm = data.user_perm; this.user_perm = data.user_perm;
this.encrypted = data.encrypted; this.encrypted = data.encrypted;
this.is_repo_owner = data.is_repo_owner; this.is_repo_owner = data.is_repo_owner;
this.is_virtual = data.is_virtual; this.is_virtual = data.is_virtual;
this.dirent_more = data.dirent_more; this.dirent_more = data.dirent_more;
this.more_start = data.more_start; this.more_start = data.more_start;
return data.dirent_list; // return the array return data.dirent_list; // return the array
}, },
// category: 'my-libs', 'shared-libs' // category: 'my-libs', 'shared-libs'

View File

@@ -14,6 +14,11 @@ define([
return Common.getUrl({name: 'group_repos', group_id: this.group_id}); return Common.getUrl({name: 'group_repos', group_id: this.group_id});
}, },
parse: function(data) {
this.is_staff = data.is_staff;
return data.repos;
},
setGroupID: function(group_id) { setGroupID: function(group_id) {
this.group_id = group_id; this.group_id = group_id;
} }

View File

@@ -12,14 +12,14 @@ define([
template: _.template($('#group-repo-tmpl').html()), template: _.template($('#group-repo-tmpl').html()),
events: { events: {
'mouseenter': 'showAction', 'mouseenter': 'highlight',
'mouseleave': 'hideAction', 'mouseleave': 'rmHighlight',
'click .cancel-share': 'unshare' 'click .cancel-share': 'unshare'
}, },
initialize: function(options) { initialize: function(options) {
this.group_id = options.group_id; this.group_id = options.group_id;
Backbone.View.prototype.initialize.apply(this, arguments); this.is_staff = options.is_staff;
this.listenTo(this.model, 'destroy', this.remove); this.listenTo(this.model, 'destroy', this.remove);
}, },
@@ -28,19 +28,18 @@ define([
var obj = this.model.toJSON(); var obj = this.model.toJSON();
$.extend(obj, { $.extend(obj, {
group_id: this.group_id, group_id: this.group_id,
is_staff: this.is_staff
}); });
this.$el.html(this.template(obj)); this.$el.html(this.template(obj));
return this; return this;
}, },
showAction: function() { highlight: function() {
this.$el.addClass('hl'); this.$el.addClass('hl').find('.op-icon').removeClass('vh');
this.$el.find('.op-icon').removeClass('vh');
}, },
hideAction: function() { rmHighlight: function() {
this.$el.removeClass('hl'); this.$el.removeClass('hl').find('.op-icon').addClass('vh');
this.$el.find('.op-icon').addClass('vh');
}, },
unshare: function() { unshare: function() {

View File

@@ -38,7 +38,11 @@ define([
}, },
addOne: function(repo, collection, options) { addOne: function(repo, collection, options) {
var view = new GroupRepoView({model: repo, group_id: this.group_id}); var view = new GroupRepoView({
model: repo,
group_id: this.group_id,
is_staff: this.repos.is_staff
});
if (options.prepend) { if (options.prepend) {
this.$tableBody.prepend(view.render().el); this.$tableBody.prepend(view.render().el);
} else { } else {