mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 07:08:55 +00:00
[group discuss] bugfix
This commit is contained in:
@@ -11,6 +11,7 @@ from seahub.api2.throttling import UserRateThrottle
|
|||||||
from seahub.api2.utils import api_error
|
from seahub.api2.utils import api_error
|
||||||
from seahub.group.models import GroupMessage
|
from seahub.group.models import GroupMessage
|
||||||
from .utils import api_check_group
|
from .utils import api_check_group
|
||||||
|
from seahub.group.utils import is_group_admin_or_owner
|
||||||
|
|
||||||
json_content_type = 'application/json; charset=utf-8'
|
json_content_type = 'application/json; charset=utf-8'
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ class GroupDiscussion(APIView):
|
|||||||
@api_check_group
|
@api_check_group
|
||||||
def delete(self, request, group_id, discuss_id, format=None):
|
def delete(self, request, group_id, discuss_id, format=None):
|
||||||
"""Remove a group discussion.
|
"""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
|
username = request.user.username
|
||||||
group_id = int(group_id)
|
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)
|
return api_error(status.HTTP_400_BAD_REQUEST, 'Discussion id %s not found.' % discuss_id)
|
||||||
|
|
||||||
# perm check
|
# 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:
|
discussion.from_email != username:
|
||||||
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
|
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ define([
|
|||||||
'shared-libs/': 'showSharedRepos',
|
'shared-libs/': 'showSharedRepos',
|
||||||
'shared-libs/lib/:repo_id(/*path)': 'showSharedRepoDir',
|
'shared-libs/lib/:repo_id(/*path)': 'showSharedRepoDir',
|
||||||
'groups/': 'showGroups',
|
'groups/': 'showGroups',
|
||||||
'group/:group_id/': 'showGroupRepos',
|
'group/:group_id/': 'showGroup',
|
||||||
'group/:group_id/lib/:repo_id(/*path)': 'showGroupRepoDir',
|
'group/:group_id/lib/:repo_id(/*path)': 'showGroupRepoDir',
|
||||||
'group/:group_id/members/': 'showGroupMembers',
|
'group/:group_id/members/': 'showGroupMembers',
|
||||||
'group/:group_id/discussions/': 'showGroupDiscussions',
|
'group/:group_id/discussions/': 'showGroupDiscussions',
|
||||||
@@ -153,9 +153,9 @@ define([
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
showGroupRepos: function(group_id) {
|
showGroup: function(group_id, options) {
|
||||||
this.switchCurrentView(this.groupView);
|
this.switchCurrentView(this.groupView);
|
||||||
this.groupView.showRepoList(group_id);
|
this.groupView.showRepoList(group_id, options);
|
||||||
this.sideNavView.setCurTab('group', {
|
this.sideNavView.setCurTab('group', {
|
||||||
'cur_group_tab': '',
|
'cur_group_tab': '',
|
||||||
'cur_group_id': group_id
|
'cur_group_id': group_id
|
||||||
@@ -177,13 +177,12 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
showGroupMembers: function(group_id) {
|
showGroupMembers: function(group_id) {
|
||||||
this.showGroupRepos(group_id);
|
this.showGroup(group_id);
|
||||||
this.groupView.showMembers();
|
this.groupView.showMembers();
|
||||||
},
|
},
|
||||||
|
|
||||||
showGroupDiscussions: function(group_id) {
|
showGroupDiscussions: function(group_id) {
|
||||||
this.showGroupRepos(group_id);
|
this.showGroup(group_id, {showDiscussions: true});
|
||||||
this.groupView.showDiscussions();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showOrgRepos: function() {
|
showOrgRepos: function() {
|
||||||
|
@@ -86,7 +86,7 @@ define([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
renderGroupTop: function() {
|
renderGroupTop: function(options) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var $groupTop = $('#group-top');
|
var $groupTop = $('#group-top');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -99,6 +99,11 @@ define([
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
_this.group = data;
|
_this.group = data;
|
||||||
$groupTop.html(_this.groupTopTemplate(data));
|
$groupTop.html(_this.groupTopTemplate(data));
|
||||||
|
if (options) {
|
||||||
|
if (options.showDiscussions) {
|
||||||
|
_this.showDiscussions();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
var err_msg;
|
var err_msg;
|
||||||
@@ -112,11 +117,11 @@ define([
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
showRepoList: function(group_id) {
|
showRepoList: function(group_id, options) {
|
||||||
this.group_id = group_id;
|
this.group_id = group_id;
|
||||||
this.dirView.hide();
|
this.dirView.hide();
|
||||||
this.$emptyTip.hide();
|
this.$emptyTip.hide();
|
||||||
this.renderGroupTop();
|
this.renderGroupTop(options);
|
||||||
this.$tabs.show();
|
this.$tabs.show();
|
||||||
this.$table.hide();
|
this.$table.hide();
|
||||||
var $loadingTip = this.$loadingTip;
|
var $loadingTip = this.$loadingTip;
|
||||||
|
Reference in New Issue
Block a user