1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +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:
repos = seaserv.get_group_repos(group.id, username)
group.is_staff = is_group_staff(group, request.user)
repos_json = []
for r in repos:
repo = {
@@ -3149,11 +3151,12 @@ class GroupRepos(APIView):
"encrypted": r.encrypted,
"permission": check_permission(r.id, username),
"owner": r.owner,
"owner_nickname": email2nickname(r.owner)
"owner_nickname": email2nickname(r.owner),
"share_from_me": r.share_from_me,
}
repos_json.append(repo)
return Response(repos_json)
return Response({"is_staff":group.is_staff, "repos":repos_json})
class GroupRepo(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)

View File

@@ -57,7 +57,7 @@
</td>
<td><a href="#group/<%= group_id %>/lib/<%= id %>"><%- name %></a></td>
<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" %}" />
<% } %>
</td>

View File

@@ -14,6 +14,11 @@ define([
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) {
this.group_id = group_id;
}

View File

@@ -12,14 +12,14 @@ define([
template: _.template($('#group-repo-tmpl').html()),
events: {
'mouseenter': 'showAction',
'mouseleave': 'hideAction',
'mouseenter': 'highlight',
'mouseleave': 'rmHighlight',
'click .cancel-share': 'unshare'
},
initialize: function(options) {
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);
},
@@ -28,19 +28,18 @@ define([
var obj = this.model.toJSON();
$.extend(obj, {
group_id: this.group_id,
is_staff: this.is_staff
});
this.$el.html(this.template(obj));
return this;
},
showAction: function() {
this.$el.addClass('hl');
this.$el.find('.op-icon').removeClass('vh');
highlight: function() {
this.$el.addClass('hl').find('.op-icon').removeClass('vh');
},
hideAction: function() {
this.$el.removeClass('hl');
this.$el.find('.op-icon').addClass('vh');
rmHighlight: function() {
this.$el.removeClass('hl').find('.op-icon').addClass('vh');
},
unshare: function() {

View File

@@ -38,7 +38,11 @@ define([
},
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) {
this.$tableBody.prepend(view.render().el);
} else {