From 14e4cc27d5d9f5ecc3ad24e8b3d42a46f17b0036 Mon Sep 17 00:00:00 2001 From: Michael An <2331806369@qq.com> Date: Mon, 2 Sep 2019 10:54:01 +0800 Subject: [PATCH 1/3] change wiki left border (#4043) --- frontend/src/pages/wiki/main-panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/wiki/main-panel.js b/frontend/src/pages/wiki/main-panel.js index b80eae05f4..59d7e07672 100644 --- a/frontend/src/pages/wiki/main-panel.js +++ b/frontend/src/pages/wiki/main-panel.js @@ -79,7 +79,7 @@ class MainPanel extends Component { const errMessage = (
{gettext('Folder does not exist.')}
); return (
-
+
{!username &&
From 5a97b20065121f1d1709d2bcc040106bba3fe798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=81=A5=E8=BE=89?= Date: Mon, 2 Sep 2019 18:11:05 +0800 Subject: [PATCH 2/3] file uuid map use origin repo_id (#4045) * file_uuid_map_use_origin_repo_id * fix test error --- seahub/tags/models.py | 14 ++++++++++ tests/seahub/base/test_models.py | 48 +++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/seahub/tags/models.py b/seahub/tags/models.py index e2877443f5..ba4a64e795 100644 --- a/seahub/tags/models.py +++ b/seahub/tags/models.py @@ -2,9 +2,12 @@ # -*- coding: utf-8 -*- import uuid import hashlib +import posixpath from django.db import models +from seaserv import seafile_api + from seahub.base.fields import LowerCaseCharField @@ -27,6 +30,7 @@ class FileUUIDMapManager(models.Manager): return: uuid of filemap """ + repo_id, parent_path = self.model.get_origin_repo_id_and_parent_path(repo_id, parent_path) uuid = self.get_fileuuidmap_by_path(repo_id, parent_path, filename, is_dir) if not uuid: uuid = self.model(repo_id=repo_id, parent_path=parent_path, @@ -44,6 +48,7 @@ class FileUUIDMapManager(models.Manager): return: return uuid if it's exist,otherwise return None """ + repo_id, parent_path = self.model.get_origin_repo_id_and_parent_path(repo_id, parent_path) md5_repo_id_parent_path = self.model.md5_repo_id_parent_path(repo_id, parent_path) uuid = super(FileUUIDMapManager, self).filter( repo_id_parent_path_md5=md5_repo_id_parent_path, @@ -55,6 +60,7 @@ class FileUUIDMapManager(models.Manager): return None def get_fileuuidmaps_by_parent_path(self, repo_id, parent_path): + repo_id, parent_path = self.model.get_origin_repo_id_and_parent_path(repo_id, parent_path) parent_path = FileUUIDMap.normalize_path(parent_path) uuids = super(FileUUIDMapManager, self).filter( repo_id=repo_id, parent_path=parent_path @@ -181,6 +187,14 @@ class FileUUIDMap(models.Model): def normalize_path(self, path): return path.rstrip('/') if path != '/' else '/' + @classmethod + def get_origin_repo_id_and_parent_path(cls, repo_id, parent_path): + repo = seafile_api.get_repo(repo_id) + if repo.is_virtual: + repo_id = repo.origin_repo_id + parent_path = posixpath.join(repo.origin_path, parent_path.strip('/')) + return repo_id, parent_path + def save(self, *args, **kwargs): self.parent_path = self.normalize_path(self.parent_path) if not self.repo_id_parent_path_md5: diff --git a/tests/seahub/base/test_models.py b/tests/seahub/base/test_models.py index 10f1a9718b..258bce8f27 100644 --- a/tests/seahub/base/test_models.py +++ b/tests/seahub/base/test_models.py @@ -6,10 +6,17 @@ from seahub.tags.models import FileUUIDMap class FileCommentManagerTest(BaseTestCase): + + def setUp(self): + self.repo_id = self.repo.id + + def tearDown(self): + self.remove_repo() + def test_can_add(self): assert len(FileComment.objects.all()) == 0 - o = FileComment.objects.add(repo_id='xxx', parent_path='/foo/bar', + o = FileComment.objects.add(repo_id=self.repo_id, parent_path='/foo/bar', item_name='test.txt', author=self.user.username, comment='test comment') @@ -20,49 +27,56 @@ class FileCommentManagerTest(BaseTestCase): assert len(FileComment.objects.all()) == 0 o = FileComment.objects.add_by_file_path( - repo_id='xxx', file_path='/foo/bar/test.txt', + repo_id=self.repo_id, file_path='/foo/bar/test.txt', author=self.user.username, comment='test comment') assert o.uuid.parent_path == '/foo/bar' assert len(FileComment.objects.all()) == 1 def test_get_by_file_path(self): - o1 = FileComment.objects.add(repo_id='xxx', parent_path='/foo/bar/', + o1 = FileComment.objects.add(repo_id=self.repo_id, parent_path='/foo/bar/', item_name='test.txt', author=self.user.username, comment='test comment 1') - o2 = FileComment.objects.add(repo_id='xxx', parent_path='/foo/bar', + o2 = FileComment.objects.add(repo_id=self.repo_id, parent_path='/foo/bar', item_name='test.txt', author=self.user.username, comment='test comment 2') - assert len(FileComment.objects.get_by_file_path('xxx', '/foo/bar/test.txt')) == 2 + assert len(FileComment.objects.get_by_file_path(self.repo_id, '/foo/bar/test.txt')) == 2 def test_get_by_parent_path(self): - o1 = FileComment.objects.add(repo_id='xxx', parent_path='/foo/bar/', + o1 = FileComment.objects.add(repo_id=self.repo_id, parent_path='/foo/bar/', item_name='test1.txt', author=self.user.username, comment='comment 1') - o2 = FileComment.objects.add(repo_id='xxx', parent_path='/foo/bar', + o2 = FileComment.objects.add(repo_id=self.repo_id, parent_path='/foo/bar', item_name='test2.txt', author=self.user.username, comment='comment 2') - assert len(FileComment.objects.get_by_parent_path('xxx', '/foo/bar/')) == 2 - assert len(FileComment.objects.get_by_parent_path('xxx', '/foo/bar')) == 2 + assert len(FileComment.objects.get_by_parent_path(self.repo_id, '/foo/bar/')) == 2 + assert len(FileComment.objects.get_by_parent_path(self.repo_id, '/foo/bar')) == 2 class FileCommentTest(BaseTestCase): + + def setUp(self): + self.repo_id = self.repo.id + + def tearDown(self): + self.remove_repo() + def test_md5_repo_id_parent_path(self): - md5 = FileUUIDMap.md5_repo_id_parent_path('xxx', '/') - assert md5 == hashlib.md5('xxx' + '/').hexdigest() + md5 = FileUUIDMap.md5_repo_id_parent_path(self.repo_id, '/') + assert md5 == hashlib.md5(self.repo_id + '/').hexdigest() - md5 = FileUUIDMap.md5_repo_id_parent_path('xxx', '/foo') - assert md5 == hashlib.md5('xxx' + '/foo').hexdigest() + md5 = FileUUIDMap.md5_repo_id_parent_path(self.repo_id, '/foo') + assert md5 == hashlib.md5(self.repo_id + '/foo').hexdigest() - md5 = FileUUIDMap.md5_repo_id_parent_path('xxx', '/foo/') - assert md5 == hashlib.md5('xxx' + '/foo').hexdigest() + md5 = FileUUIDMap.md5_repo_id_parent_path(self.repo_id, '/foo/') + assert md5 == hashlib.md5(self.repo_id + '/foo').hexdigest() def test_normalize_path(self): - o = FileComment.objects.add(repo_id='xxx', parent_path='/foo/bar/', + o = FileComment.objects.add(repo_id=self.repo_id, parent_path='/foo/bar/', item_name='test.txt', author=self.user.username, comment='test comment') @@ -70,7 +84,7 @@ class FileCommentTest(BaseTestCase): def test_can_save(self): assert len(FileComment.objects.all()) == 0 - uuid = FileUUIDMap.objects.get_or_create_fileuuidmap('xxx', '/foo/bar/', 'test.txt', False) + uuid = FileUUIDMap.objects.get_or_create_fileuuidmap(self.repo_id, '/foo/bar/', 'test.txt', False) FileComment(uuid=uuid, author=self.user.username, comment='test comment').save() From 169ee131c98968ec3e900a312bd022dd657d88ca Mon Sep 17 00:00:00 2001 From: llj Date: Tue, 3 Sep 2019 10:40:19 +0800 Subject: [PATCH 3/3] fixed '.sf-heading' UI (#4047) --- media/css/seahub_react.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/media/css/seahub_react.css b/media/css/seahub_react.css index d88ec6cb01..de43d35514 100644 --- a/media/css/seahub_react.css +++ b/media/css/seahub_react.css @@ -142,6 +142,9 @@ ul,ol,li { font-weight: normal; line-height: 1.5; } +.cur-view-path .sf-heading { + margin: 0; +} .vh { visibility: hidden;