diff --git a/frontend/src/models/activity.js b/frontend/src/models/activity.js
index 70cb721e3c..f7e0ed044a 100644
--- a/frontend/src/models/activity.js
+++ b/frontend/src/models/activity.js
@@ -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;
}
}
}
diff --git a/frontend/src/pages/dashboard/files-activities.js b/frontend/src/pages/dashboard/files-activities.js
index c2ff6a3c0b..412970a816 100644
--- a/frontend/src/pages/dashboard/files-activities.js
+++ b/frontend/src/pages/dashboard/files-activities.js
@@ -122,23 +122,11 @@ class ActivityItem extends Component {
details =
{libLink} | ;
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 = {item.name};
- switch(item.op_type) {
- case 'open':
- op = gettext('Open review');
- details = {fileLink} {smallLibLink} | ;
- break;
- case 'closed':
- op = gettext('Close review');
- details = {fileLink} {smallLibLink} | ;
- break;
- case 'finished':
- op = gettext('Publish draft');
- details = {fileLink} {smallLibLink} | ;
- break;
- }
+ op = gettext('Publish draft');
+ details = {fileLink} {smallLibLink} | ;
} else if (item.obj_type == 'files') {
let fileURL = `${siteRoot}lib/${item.repo_id}/file${Utils.encodePath(item.path)}`;
let fileLink = `${item.name}`;
@@ -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,
diff --git a/seahub/api2/endpoints/activities.py b/seahub/api2/endpoints/activities.py
index c9fb09b4d3..a45b2966f8 100644
--- a/seahub/api2/endpoints/activities.py
+++ b/seahub/api2/endpoints/activities.py
@@ -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)
diff --git a/seahub/api2/endpoints/drafts.py b/seahub/api2/endpoints/drafts.py
index 124565b20b..7b85fb1449 100644
--- a/seahub/api2/endpoints/drafts.py
+++ b/seahub/api2/endpoints/drafts.py
@@ -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,
diff --git a/seahub/drafts/utils.py b/seahub/drafts/utils.py
index 49fea7b334..3c5ac18adf 100644
--- a/seahub/drafts/utils.py
+++ b/seahub/drafts/utils.py
@@ -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))