mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +00:00
replace path with UUID (#2500)
This commit is contained in:
@@ -95,7 +95,7 @@ class DraftReview extends React.Component {
|
||||
msg_s = msg_s.replace('%(reviewID)s', reviewID);
|
||||
Toast.success(msg_s);
|
||||
}).catch(() => {
|
||||
let msg_s = gettext('Failed to close review %(reviewID)s.')
|
||||
let msg_s = gettext('Failed to publish review %(reviewID)s.')
|
||||
msg_s = msg_s.replace('%(reviewID)s', reviewID);
|
||||
Toast.error(msg_s);
|
||||
});
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# Copyright (c) 2012-2016 Seafile Ltd.
|
||||
import os
|
||||
import posixpath
|
||||
|
||||
from rest_framework import status
|
||||
from rest_framework.authentication import SessionAuthentication
|
||||
@@ -106,12 +107,13 @@ class DraftReviewView(APIView):
|
||||
return api_error(status.HTTP_409_CONFLICT,
|
||||
'There is a conflict between the draft and the original file')
|
||||
|
||||
origin_file_path = r.origin_file_path
|
||||
uuid = r.origin_file_uuid
|
||||
origin_file_path = posixpath.join(uuid.parent_path, uuid.filename)
|
||||
|
||||
# if it is a new draft
|
||||
# case1. '/path/test(draft).md' ---> '/path/test.md'
|
||||
# case2. '/path/test(dra.md' ---> '/path/test(dra.md'
|
||||
if d.draft_file_path == r.origin_file_path:
|
||||
if d.draft_file_path == origin_file_path:
|
||||
new_draft_dir = os.path.dirname(origin_file_path)
|
||||
new_draft_name = os.path.basename(origin_file_path)
|
||||
|
||||
@@ -129,7 +131,6 @@ class DraftReviewView(APIView):
|
||||
origin_file_path = new_draft_dir + '/' + new_draft_name
|
||||
|
||||
r.draft_file_path = origin_file_path
|
||||
r.origin_file_path = origin_file_path
|
||||
|
||||
# get draft published version
|
||||
file_id = seafile_api.get_file_id_by_path(r.origin_repo_id, origin_file_path)
|
||||
|
27
seahub/drafts/migrations/0004_auto_20181102_1007.py
Normal file
27
seahub/drafts/migrations/0004_auto_20181102_1007.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.15 on 2018-11-02 10:07
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tags', '0001_initial'),
|
||||
('drafts', '0003_reviewcomment'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='draftreview',
|
||||
name='origin_file_path',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='draftreview',
|
||||
name='origin_file_uuid',
|
||||
field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='tags.FileUUIDMap'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
@@ -164,14 +164,11 @@ class DraftReviewManager(models.Manager):
|
||||
if has_review:
|
||||
raise DraftReviewExist
|
||||
|
||||
uuid = draft.origin_file_uuid
|
||||
file_path = posixpath.join(uuid.parent_path, uuid.filename)
|
||||
|
||||
draft_review = self.model(creator=creator,
|
||||
status='open',
|
||||
draft_id=draft,
|
||||
origin_repo_id=draft.origin_repo_id,
|
||||
origin_file_path=file_path,
|
||||
origin_file_uuid=draft.origin_file_uuid,
|
||||
draft_file_path=draft.draft_file_path,
|
||||
origin_file_version=draft.origin_file_version)
|
||||
draft_review.save(using=self._db)
|
||||
@@ -183,7 +180,7 @@ class DraftReview(TimestampedModel):
|
||||
creator = LowerCaseCharField(max_length=255, db_index=True)
|
||||
status = models.CharField(max_length=20)
|
||||
origin_repo_id = models.CharField(max_length=36)
|
||||
origin_file_path = models.CharField(max_length=1024)
|
||||
origin_file_uuid = models.ForeignKey(FileUUIDMap, on_delete=models.CASCADE)
|
||||
draft_file_path = models.CharField(max_length=1024)
|
||||
origin_file_version = models.CharField(max_length=100)
|
||||
publish_file_version = models.CharField(max_length=100, null=True)
|
||||
@@ -196,6 +193,9 @@ class DraftReview(TimestampedModel):
|
||||
if not r_repo:
|
||||
raise DraftFileConflict
|
||||
|
||||
uuid = self.origin_file_uuid
|
||||
file_path = posixpath.join(uuid.parent_path, uuid.filename)
|
||||
|
||||
return {
|
||||
'id': self.pk,
|
||||
'creator': self.creator,
|
||||
@@ -203,7 +203,7 @@ class DraftReview(TimestampedModel):
|
||||
'creator_name': email2nickname(self.creator),
|
||||
'draft_origin_repo_id': self.origin_repo_id,
|
||||
'draft_origin_repo_name': r_repo.name,
|
||||
'draft_origin_file_path': self.origin_file_path,
|
||||
'draft_origin_file_path': file_path,
|
||||
'draft_origin_file_version': self.origin_file_version,
|
||||
'draft_publish_file_version': self.publish_file_version,
|
||||
'draft_file_path': self.draft_file_path,
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import posixpath
|
||||
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.utils.translation import ugettext as _
|
||||
@@ -9,6 +10,7 @@ from seahub.views import check_folder_permission
|
||||
from seahub.utils import render_permission_error
|
||||
from seahub.drafts.models import Draft, DraftReview
|
||||
|
||||
|
||||
@login_required
|
||||
def drafts(request):
|
||||
return render(request, "react_app.html")
|
||||
@@ -24,7 +26,9 @@ def review(request, pk):
|
||||
d_r = get_object_or_404(DraftReview, pk=pk)
|
||||
|
||||
# check perm
|
||||
file_path = d_r.origin_file_path
|
||||
uuid = d_r.origin_file_uuid
|
||||
file_path = posixpath.join(uuid.parent_path, uuid.filename)
|
||||
|
||||
origin_repo_id = d_r.origin_repo_id
|
||||
|
||||
if request.user.username:
|
||||
@@ -40,7 +44,7 @@ def review(request, pk):
|
||||
"review_id": pk,
|
||||
"draft_repo_id": d_r.origin_repo_id,
|
||||
"draft_origin_repo_id": d_r.origin_repo_id,
|
||||
"draft_origin_file_path": d_r.origin_file_path,
|
||||
"draft_origin_file_path": file_path,
|
||||
"draft_file_path": d_r.draft_file_path,
|
||||
"draft_file_name": draft_file_name,
|
||||
"origin_file_version": d_r.origin_file_version,
|
||||
|
Reference in New Issue
Block a user