1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-15 23:00:57 +00:00

[group discuss] bugfix

This commit is contained in:
llj
2016-03-28 18:12:25 +08:00
parent fa022ed9df
commit 8763a32af8
3 changed files with 17 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ from seahub.api2.throttling import UserRateThrottle
from seahub.api2.utils import api_error
from seahub.group.models import GroupMessage
from .utils import api_check_group
from seahub.group.utils import is_group_admin_or_owner
json_content_type = 'application/json; charset=utf-8'
@@ -22,7 +23,7 @@ class GroupDiscussion(APIView):
@api_check_group
def delete(self, request, group_id, discuss_id, format=None):
"""Remove a group discussion.
Only discussion creator or group admin can perform this op.
Only discussion creator or group owner/admin can perform this op.
"""
username = request.user.username
group_id = int(group_id)
@@ -33,7 +34,7 @@ class GroupDiscussion(APIView):
return api_error(status.HTTP_400_BAD_REQUEST, 'Discussion id %s not found.' % discuss_id)
# perm check
if not ccnet_api.check_group_staff(group_id, username) and \
if not is_group_admin_or_owner(group_id, username) and \
discussion.from_email != username:
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')

View File

@@ -21,7 +21,7 @@ define([
'shared-libs/': 'showSharedRepos',
'shared-libs/lib/:repo_id(/*path)': 'showSharedRepoDir',
'groups/': 'showGroups',
'group/:group_id/': 'showGroupRepos',
'group/:group_id/': 'showGroup',
'group/:group_id/lib/:repo_id(/*path)': 'showGroupRepoDir',
'group/:group_id/members/': 'showGroupMembers',
'group/:group_id/discussions/': 'showGroupDiscussions',
@@ -153,9 +153,9 @@ define([
});
},
showGroupRepos: function(group_id) {
showGroup: function(group_id, options) {
this.switchCurrentView(this.groupView);
this.groupView.showRepoList(group_id);
this.groupView.showRepoList(group_id, options);
this.sideNavView.setCurTab('group', {
'cur_group_tab': '',
'cur_group_id': group_id
@@ -177,13 +177,12 @@ define([
},
showGroupMembers: function(group_id) {
this.showGroupRepos(group_id);
this.showGroup(group_id);
this.groupView.showMembers();
},
showGroupDiscussions: function(group_id) {
this.showGroupRepos(group_id);
this.groupView.showDiscussions();
this.showGroup(group_id, {showDiscussions: true});
},
showOrgRepos: function() {

View File

@@ -86,7 +86,7 @@ define([
}
},
renderGroupTop: function() {
renderGroupTop: function(options) {
var _this = this;
var $groupTop = $('#group-top');
$.ajax({
@@ -99,6 +99,11 @@ define([
success: function (data) {
_this.group = data;
$groupTop.html(_this.groupTopTemplate(data));
if (options) {
if (options.showDiscussions) {
_this.showDiscussions();
}
}
},
error: function(xhr) {
var err_msg;
@@ -112,11 +117,11 @@ define([
});
},
showRepoList: function(group_id) {
showRepoList: function(group_id, options) {
this.group_id = group_id;
this.dirView.hide();
this.$emptyTip.hide();
this.renderGroupTop();
this.renderGroupTop(options);
this.$tabs.show();
this.$table.hide();
var $loadingTip = this.$loadingTip;