mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 17:33:18 +00:00
remove review event (#3089)
* remove review event * draft publish event
This commit is contained in:
@@ -23,9 +23,8 @@ class Acticity {
|
||||
} else if (json.op_type === 'rename' && ['dir', 'file'].includes(json.obj_type)) {
|
||||
this.old_path = json.old_path;
|
||||
this.old_name = json.old_name;
|
||||
} else if (json.obj_type === 'review') {
|
||||
} else if (json.op_type === 'publish') {
|
||||
this.old_path = json.old_path;
|
||||
this.review_id = json.review_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -122,23 +122,11 @@ class ActivityItem extends Component {
|
||||
details = <td>{libLink}</td>;
|
||||
break;
|
||||
}
|
||||
} else if (item.obj_type == 'review') {
|
||||
let fileURL = `${siteRoot}drafts/review/${item.review_id}`;
|
||||
} else if (item.obj_type == 'draft') {
|
||||
let fileURL = `${siteRoot}lib/${item.repo_id}/file${Utils.encodePath(item.path)}`;
|
||||
let fileLink = <a href={fileURL} target="_blank">{item.name}</a>;
|
||||
switch(item.op_type) {
|
||||
case 'open':
|
||||
op = gettext('Open review');
|
||||
details = <td>{fileLink}<br />{smallLibLink}</td>;
|
||||
break;
|
||||
case 'closed':
|
||||
op = gettext('Close review');
|
||||
details = <td>{fileLink}<br />{smallLibLink}</td>;
|
||||
break;
|
||||
case 'finished':
|
||||
op = gettext('Publish draft');
|
||||
details = <td>{fileLink}<br />{smallLibLink}</td>;
|
||||
break;
|
||||
}
|
||||
} else if (item.obj_type == 'files') {
|
||||
let fileURL = `${siteRoot}lib/${item.repo_id}/file${Utils.encodePath(item.path)}`;
|
||||
let fileLink = `<a href=${fileURL} target="_blank">${item.name}</a>`;
|
||||
@@ -287,7 +275,7 @@ class FilesActivities extends Component {
|
||||
let currentPage = this.state.currentPage;
|
||||
seafileAPI.listActivities(currentPage, this.avatarSize).then(res => {
|
||||
// {"events":[...]}
|
||||
let events = this.mergeReviewEvents(res.data.events);
|
||||
let events = this.mergePublishEvents(res.data.events);
|
||||
events = this.mergeFileCreateEvents(events);
|
||||
this.setState({
|
||||
items: events,
|
||||
@@ -308,9 +296,9 @@ class FilesActivities extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
mergeReviewEvents = (events) => {
|
||||
mergePublishEvents = (events) => {
|
||||
events.map((item) => {
|
||||
if (item.op_type === 'finished') {
|
||||
if (item.op_type === 'publish') {
|
||||
this.curPathList.push(item.path);
|
||||
this.oldPathList.push(item.old_path);
|
||||
}
|
||||
@@ -372,7 +360,7 @@ class FilesActivities extends Component {
|
||||
let currentPage = this.state.currentPage;
|
||||
seafileAPI.listActivities(currentPage, this.avatarSize).then(res => {
|
||||
// {"events":[...]}
|
||||
let events = this.mergeReviewEvents(res.data.events);
|
||||
let events = this.mergePublishEvents(res.data.events);
|
||||
events = this.mergeFileCreateEvents(events);
|
||||
this.setState({
|
||||
isLoadingMore: false,
|
||||
|
@@ -83,9 +83,8 @@ class ActivitiesView(APIView):
|
||||
elif e.op_type == 'rename' and e.obj_type in ['dir', 'file']:
|
||||
d['old_path'] = e.old_path
|
||||
d['old_name'] = os.path.basename(e.old_path)
|
||||
elif e.obj_type == 'review':
|
||||
elif e.op_type == 'publish':
|
||||
d['old_path'] = e.old_path
|
||||
d['review_id'] = e.review_id
|
||||
|
||||
events_list.append(d)
|
||||
|
||||
|
@@ -23,6 +23,7 @@ from seahub.drafts.models import Draft, DraftFileExist, DraftFileConflict
|
||||
from seahub.tags.models import FileUUIDMap
|
||||
from seahub.views import check_folder_permission
|
||||
from seahub.utils import gen_file_get_url
|
||||
from seahub.drafts.utils import send_draft_publish_msg
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -119,6 +120,7 @@ class DraftView(APIView):
|
||||
username = request.user.username
|
||||
try:
|
||||
published_file_path = d.publish(operator=username)
|
||||
send_draft_publish_msg(d, username, published_file_path)
|
||||
return Response({'published_file_path': published_file_path})
|
||||
except DraftFileConflict:
|
||||
return api_error(status.HTTP_409_CONFLICT,
|
||||
|
@@ -103,36 +103,18 @@ def get_file_draft(repo_id, file_path, is_draft=False, has_draft=False):
|
||||
return draft
|
||||
|
||||
|
||||
def send_review_status_msg(request, review):
|
||||
def send_draft_publish_msg(draft, username, path):
|
||||
"""
|
||||
send review status change to seafevents
|
||||
send draft publish msg to seafevents
|
||||
"""
|
||||
status = review.status.lower()
|
||||
if status not in ['open', 'finished', 'closed']:
|
||||
logger.warn('Invalid status in review status msg: %s' % status)
|
||||
return
|
||||
|
||||
repo_id = review.origin_repo_id
|
||||
op_user = request.user.username
|
||||
review_id = review.id
|
||||
draft_flag = os.path.splitext(os.path.basename(review.draft_file_path))[0][-7:]
|
||||
if draft_flag == '(draft)':
|
||||
old_path = review.draft_file_path
|
||||
if status == 'finished':
|
||||
publish_path = posixpath.join(review.origin_file_uuid.parent_path, review.origin_file_uuid.filename)
|
||||
else:
|
||||
publish_path = None
|
||||
else:
|
||||
old_path = posixpath.join(review.origin_file_uuid.parent_path, review.origin_file_uuid.filename)
|
||||
publish_path = review.draft_file_path if status == 'finished' else None
|
||||
path = publish_path if publish_path else old_path
|
||||
repo_id = draft.origin_repo_id
|
||||
old_path = draft.draft_file_path
|
||||
|
||||
creator = review.creator
|
||||
|
||||
msg = '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s' % (status, repo_id, op_user, "review", path, review_id, old_path, creator)
|
||||
msg = '%s\t%s\t%s\t%s\t%s\t%s' % ("publish", "draft", repo_id, username, path, old_path)
|
||||
msg_utf8 = msg.encode('utf-8')
|
||||
|
||||
try:
|
||||
send_message('seahub.review', msg_utf8)
|
||||
send_message('seahub.draft', msg_utf8)
|
||||
except Exception as e:
|
||||
logger.error("Error when sending %s message: %s" % (status, str(e)))
|
||||
logger.error("Error when sending draft publish message: %s" % str(e))
|
||||
|
Reference in New Issue
Block a user