From 55dd843bd05b7d5292a08b18bbff5084d9e84878 Mon Sep 17 00:00:00 2001 From: ilearnit Date: Thu, 7 Mar 2019 08:41:56 +0000 Subject: [PATCH] update draft --- frontend/src/draft.js | 2 +- frontend/src/markdown-editor.js | 2 +- seahub/api2/endpoints/drafts.py | 4 ++-- seahub/drafts/models.py | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/draft.js b/frontend/src/draft.js index b0ae881e4a..e1eabc0df7 100644 --- a/frontend/src/draft.js +++ b/frontend/src/draft.js @@ -378,8 +378,8 @@ class Draft extends React.Component { } onPublishDraft = () => { - const OriginFileLink = siteRoot + 'lib/' + draftRepoID + '/file' + draftOriginFilePath + '/'; seafileAPI.publishDraft(draftID).then(res => { + const OriginFileLink = siteRoot + 'lib/' + draftRepoID + '/file' + encodeURIComponent(res.data.published_file_path) + '/'; window.location.href = OriginFileLink; }); } diff --git a/frontend/src/markdown-editor.js b/frontend/src/markdown-editor.js index 3343665cd7..5de47312eb 100644 --- a/frontend/src/markdown-editor.js +++ b/frontend/src/markdown-editor.js @@ -230,7 +230,7 @@ class EditorUtilities { publishDraftFile() { return seafileAPI.publishDraft(draftID).then(res => { - window.location.href = serviceUrl + '/lib/' + repoID + '/file' + encodeURIComponent(draftOriginFilePath); + window.location.href = serviceUrl + '/lib/' + repoID + '/file' + encodeURIComponent(res.data.published_file_path); }); } diff --git a/seahub/api2/endpoints/drafts.py b/seahub/api2/endpoints/drafts.py index 0c4a17a2fa..124565b20b 100644 --- a/seahub/api2/endpoints/drafts.py +++ b/seahub/api2/endpoints/drafts.py @@ -118,8 +118,8 @@ class DraftView(APIView): username = request.user.username try: - d.publish(operator=username) - return Response(status.HTTP_200_OK) + published_file_path = d.publish(operator=username) + return Response({'published_file_path': published_file_path}) except DraftFileConflict: return api_error(status.HTTP_409_CONFLICT, 'There is a conflict between the draft and the original file') diff --git a/seahub/drafts/models.py b/seahub/drafts/models.py index b428e96e3b..e4d8e05d78 100644 --- a/seahub/drafts/models.py +++ b/seahub/drafts/models.py @@ -243,6 +243,10 @@ class Draft(TimestampedModel): ) self.delete(operator) + + published_file_path = posixpath.join(file_uuid.parent_path, file_name) + + return published_file_path # get draft published version # file_id = seafile_api.get_file_id_by_path(self.origin_repo_id, origin_file_path)