mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 17:02:47 +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)) {
|
} else if (json.op_type === 'rename' && ['dir', 'file'].includes(json.obj_type)) {
|
||||||
this.old_path = json.old_path;
|
this.old_path = json.old_path;
|
||||||
this.old_name = json.old_name;
|
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.old_path = json.old_path;
|
||||||
this.review_id = json.review_id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -122,23 +122,11 @@ class ActivityItem extends Component {
|
|||||||
details = <td>{libLink}</td>;
|
details = <td>{libLink}</td>;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (item.obj_type == 'review') {
|
} else if (item.obj_type == 'draft') {
|
||||||
let fileURL = `${siteRoot}drafts/review/${item.review_id}`;
|
let fileURL = `${siteRoot}lib/${item.repo_id}/file${Utils.encodePath(item.path)}`;
|
||||||
let fileLink = <a href={fileURL} target="_blank">{item.name}</a>;
|
let fileLink = <a href={fileURL} target="_blank">{item.name}</a>;
|
||||||
switch(item.op_type) {
|
op = gettext('Publish draft');
|
||||||
case 'open':
|
details = <td>{fileLink}<br />{smallLibLink}</td>;
|
||||||
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') {
|
} else if (item.obj_type == 'files') {
|
||||||
let fileURL = `${siteRoot}lib/${item.repo_id}/file${Utils.encodePath(item.path)}`;
|
let fileURL = `${siteRoot}lib/${item.repo_id}/file${Utils.encodePath(item.path)}`;
|
||||||
let fileLink = `<a href=${fileURL} target="_blank">${item.name}</a>`;
|
let fileLink = `<a href=${fileURL} target="_blank">${item.name}</a>`;
|
||||||
@@ -287,7 +275,7 @@ class FilesActivities extends Component {
|
|||||||
let currentPage = this.state.currentPage;
|
let currentPage = this.state.currentPage;
|
||||||
seafileAPI.listActivities(currentPage, this.avatarSize).then(res => {
|
seafileAPI.listActivities(currentPage, this.avatarSize).then(res => {
|
||||||
// {"events":[...]}
|
// {"events":[...]}
|
||||||
let events = this.mergeReviewEvents(res.data.events);
|
let events = this.mergePublishEvents(res.data.events);
|
||||||
events = this.mergeFileCreateEvents(events);
|
events = this.mergeFileCreateEvents(events);
|
||||||
this.setState({
|
this.setState({
|
||||||
items: events,
|
items: events,
|
||||||
@@ -308,9 +296,9 @@ class FilesActivities extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeReviewEvents = (events) => {
|
mergePublishEvents = (events) => {
|
||||||
events.map((item) => {
|
events.map((item) => {
|
||||||
if (item.op_type === 'finished') {
|
if (item.op_type === 'publish') {
|
||||||
this.curPathList.push(item.path);
|
this.curPathList.push(item.path);
|
||||||
this.oldPathList.push(item.old_path);
|
this.oldPathList.push(item.old_path);
|
||||||
}
|
}
|
||||||
@@ -372,7 +360,7 @@ class FilesActivities extends Component {
|
|||||||
let currentPage = this.state.currentPage;
|
let currentPage = this.state.currentPage;
|
||||||
seafileAPI.listActivities(currentPage, this.avatarSize).then(res => {
|
seafileAPI.listActivities(currentPage, this.avatarSize).then(res => {
|
||||||
// {"events":[...]}
|
// {"events":[...]}
|
||||||
let events = this.mergeReviewEvents(res.data.events);
|
let events = this.mergePublishEvents(res.data.events);
|
||||||
events = this.mergeFileCreateEvents(events);
|
events = this.mergeFileCreateEvents(events);
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoadingMore: false,
|
isLoadingMore: false,
|
||||||
|
@@ -83,9 +83,8 @@ class ActivitiesView(APIView):
|
|||||||
elif e.op_type == 'rename' and e.obj_type in ['dir', 'file']:
|
elif e.op_type == 'rename' and e.obj_type in ['dir', 'file']:
|
||||||
d['old_path'] = e.old_path
|
d['old_path'] = e.old_path
|
||||||
d['old_name'] = os.path.basename(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['old_path'] = e.old_path
|
||||||
d['review_id'] = e.review_id
|
|
||||||
|
|
||||||
events_list.append(d)
|
events_list.append(d)
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@ from seahub.drafts.models import Draft, DraftFileExist, DraftFileConflict
|
|||||||
from seahub.tags.models import FileUUIDMap
|
from seahub.tags.models import FileUUIDMap
|
||||||
from seahub.views import check_folder_permission
|
from seahub.views import check_folder_permission
|
||||||
from seahub.utils import gen_file_get_url
|
from seahub.utils import gen_file_get_url
|
||||||
|
from seahub.drafts.utils import send_draft_publish_msg
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -119,6 +120,7 @@ class DraftView(APIView):
|
|||||||
username = request.user.username
|
username = request.user.username
|
||||||
try:
|
try:
|
||||||
published_file_path = d.publish(operator=username)
|
published_file_path = d.publish(operator=username)
|
||||||
|
send_draft_publish_msg(d, username, published_file_path)
|
||||||
return Response({'published_file_path': published_file_path})
|
return Response({'published_file_path': published_file_path})
|
||||||
except DraftFileConflict:
|
except DraftFileConflict:
|
||||||
return api_error(status.HTTP_409_CONFLICT,
|
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
|
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
|
repo_id = draft.origin_repo_id
|
||||||
op_user = request.user.username
|
old_path = draft.draft_file_path
|
||||||
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
|
|
||||||
|
|
||||||
creator = review.creator
|
msg = '%s\t%s\t%s\t%s\t%s\t%s' % ("publish", "draft", repo_id, username, path, old_path)
|
||||||
|
|
||||||
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_utf8 = msg.encode('utf-8')
|
msg_utf8 = msg.encode('utf-8')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
send_message('seahub.review', msg_utf8)
|
send_message('seahub.draft', msg_utf8)
|
||||||
except Exception as e:
|
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