|
@@ -10,6 +10,8 @@ from tracim.lib.content import ContentApi
|
10
|
10
|
from tracim.lib.user import UserApi
|
11
|
11
|
from tracim.lib.webdav import HistoryType
|
12
|
12
|
from tracim.lib.webdav import FakeFileStream
|
|
13
|
+from tracim.lib.webdav.utils import transform_to_display
|
|
14
|
+from tracim.lib.webdav.utils import transform_to_bdd
|
13
|
15
|
from tracim.lib.workspace import WorkspaceApi
|
14
|
16
|
from tracim.model import data, new_revision
|
15
|
17
|
from tracim.model.data import Content, ActionDescription
|
|
@@ -121,7 +123,7 @@ class Root(DAVCollection):
|
121
|
123
|
"""
|
122
|
124
|
try:
|
123
|
125
|
workspace = self.workspace_api.get_one_by_label(label)
|
124
|
|
- workspace_path = '%s%s%s' % (self.path, '' if self.path == '/' else '/', self.provider.transform_to_display(workspace.label))
|
|
126
|
+ workspace_path = '%s%s%s' % (self.path, '' if self.path == '/' else '/', transform_to_display(workspace.label))
|
125
|
127
|
|
126
|
128
|
return Workspace(workspace_path, self.environ, workspace)
|
127
|
129
|
except AttributeError:
|
|
@@ -152,7 +154,7 @@ class Root(DAVCollection):
|
152
|
154
|
self.workspace_api.save(new_workspace)
|
153
|
155
|
|
154
|
156
|
workspace_path = '%s%s%s' % (
|
155
|
|
- self.path, '' if self.path == '/' else '/', self.provider.transform_to_display(new_workspace.label))
|
|
157
|
+ self.path, '' if self.path == '/' else '/', transform_to_display(new_workspace.label))
|
156
|
158
|
|
157
|
159
|
transaction.commit()
|
158
|
160
|
return Workspace(workspace_path, self.environ, new_workspace)
|
|
@@ -222,7 +224,7 @@ class Workspace(DAVCollection):
|
222
|
224
|
def getMember(self, content_label: str) -> _DAVResource:
|
223
|
225
|
|
224
|
226
|
return self.provider.getResourceInst(
|
225
|
|
- '%s/%s' % (self.path, self.provider.transform_to_display(content_label)),
|
|
227
|
+ '%s/%s' % (self.path, transform_to_display(content_label)),
|
226
|
228
|
self.environ
|
227
|
229
|
)
|
228
|
230
|
|
|
@@ -275,7 +277,7 @@ class Workspace(DAVCollection):
|
275
|
277
|
|
276
|
278
|
transaction.commit()
|
277
|
279
|
|
278
|
|
- return Folder('%s/%s' % (self.path, self.provider.transform_to_display(label)),
|
|
280
|
+ return Folder('%s/%s' % (self.path, transform_to_display(label)),
|
279
|
281
|
self.environ, folder,
|
280
|
282
|
self.workspace)
|
281
|
283
|
|
|
@@ -299,7 +301,7 @@ class Workspace(DAVCollection):
|
299
|
301
|
children = self.content_api.get_all(False, ContentType.Any, self.workspace)
|
300
|
302
|
|
301
|
303
|
for content in children:
|
302
|
|
- content_path = '%s/%s' % (self.path, self.provider.transform_to_display(content.get_label()))
|
|
304
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
303
|
305
|
|
304
|
306
|
if content.type == ContentType.Folder:
|
305
|
307
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -363,7 +365,7 @@ class Folder(Workspace):
|
363
|
365
|
return mktime(self.content.created.timetuple())
|
364
|
366
|
|
365
|
367
|
def getDisplayName(self) -> str:
|
366
|
|
- return self.provider.transform_to_display(self.content.get_label())
|
|
368
|
+ return transform_to_display(self.content.get_label())
|
367
|
369
|
|
368
|
370
|
def getLastModified(self) -> float:
|
369
|
371
|
return mktime(self.content.updated.timetuple())
|
|
@@ -441,7 +443,7 @@ class Folder(Workspace):
|
441
|
443
|
|
442
|
444
|
with new_revision(self.content):
|
443
|
445
|
if basename(destpath) != self.getDisplayName():
|
444
|
|
- self.content_api.update_content(self.content, self.provider.transform_to_bdd(basename(destpath)))
|
|
446
|
+ self.content_api.update_content(self.content, transform_to_bdd(basename(destpath)))
|
445
|
447
|
self.content_api.save(self.content)
|
446
|
448
|
else:
|
447
|
449
|
if workspace.workspace_id == self.content.workspace.workspace_id:
|
|
@@ -461,7 +463,7 @@ class Folder(Workspace):
|
461
|
463
|
)
|
462
|
464
|
|
463
|
465
|
for content in visible_children:
|
464
|
|
- content_path = '%s/%s' % (self.path, self.provider.transform_to_display(content.get_label()))
|
|
466
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
465
|
467
|
|
466
|
468
|
if content.type == ContentType.Folder:
|
467
|
469
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -627,7 +629,7 @@ class DeletedFolder(HistoryFolder):
|
627
|
629
|
)
|
628
|
630
|
|
629
|
631
|
return self.provider.getResourceInst(
|
630
|
|
- path='%s/%s' % (self.path, self.provider.transform_to_display(content.get_label())),
|
|
632
|
+ path='%s/%s' % (self.path, transform_to_display(content.get_label())),
|
631
|
633
|
environ=self.environ
|
632
|
634
|
)
|
633
|
635
|
|
|
@@ -658,7 +660,7 @@ class DeletedFolder(HistoryFolder):
|
658
|
660
|
|
659
|
661
|
for content in children:
|
660
|
662
|
if content.is_deleted:
|
661
|
|
- content_path = '%s/%s' % (self.path, self.provider.transform_to_display(content.get_label()))
|
|
663
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
662
|
664
|
|
663
|
665
|
if content.type == ContentType.Folder:
|
664
|
666
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -712,7 +714,7 @@ class ArchivedFolder(HistoryFolder):
|
712
|
714
|
)
|
713
|
715
|
|
714
|
716
|
return self.provider.getResourceInst(
|
715
|
|
- path=self.path + '/' + self.provider.transform_to_display(content.get_label()),
|
|
717
|
+ path=self.path + '/' + transform_to_display(content.get_label()),
|
716
|
718
|
environ=self.environ
|
717
|
719
|
)
|
718
|
720
|
|
|
@@ -738,7 +740,7 @@ class ArchivedFolder(HistoryFolder):
|
738
|
740
|
|
739
|
741
|
for content in children:
|
740
|
742
|
if content.is_archived:
|
741
|
|
- content_path = '%s/%s' % (self.path, self.provider.transform_to_display(content.get_label()))
|
|
743
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
742
|
744
|
|
743
|
745
|
if content.type == ContentType.Folder:
|
744
|
746
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -800,13 +802,13 @@ class HistoryFileFolder(HistoryFolder):
|
800
|
802
|
|
801
|
803
|
if self.content.type == ContentType.File:
|
802
|
804
|
return HistoryFile(
|
803
|
|
- path='%s%s' % (left_side, self.provider.transform_to_display(revision.file_name)),
|
|
805
|
+ path='%s%s' % (left_side, transform_to_display(revision.file_name)),
|
804
|
806
|
environ=self.environ,
|
805
|
807
|
content=self.content,
|
806
|
808
|
content_revision=revision)
|
807
|
809
|
else:
|
808
|
810
|
return HistoryOtherFile(
|
809
|
|
- path='%s%s' % (left_side, self.provider.transform_to_display(revision.get_label())),
|
|
811
|
+ path='%s%s' % (left_side, transform_to_display(revision.get_label())),
|
810
|
812
|
environ=self.environ,
|
811
|
813
|
content=self.content,
|
812
|
814
|
content_revision=revision)
|
|
@@ -820,14 +822,14 @@ class HistoryFileFolder(HistoryFolder):
|
820
|
822
|
|
821
|
823
|
if self.content.type == ContentType.File:
|
822
|
824
|
members.append(HistoryFile(
|
823
|
|
- path='%s%s' % (left_side, self.provider.transform_to_display(content.file_name)),
|
|
825
|
+ path='%s%s' % (left_side, transform_to_display(content.file_name)),
|
824
|
826
|
environ=self.environ,
|
825
|
827
|
content=self.content,
|
826
|
828
|
content_revision=content)
|
827
|
829
|
)
|
828
|
830
|
else:
|
829
|
831
|
members.append(HistoryOtherFile(
|
830
|
|
- path='%s%s' % (left_side, self.provider.transform_to_display(content.file_name)),
|
|
832
|
+ path='%s%s' % (left_side, transform_to_display(content.file_name)),
|
831
|
833
|
environ=self.environ,
|
832
|
834
|
content=self.content,
|
833
|
835
|
content_revision=content)
|
|
@@ -992,7 +994,7 @@ class HistoryFile(File):
|
992
|
994
|
|
993
|
995
|
def getDisplayName(self) -> str:
|
994
|
996
|
left_side = '(%d - %s) ' % (self.content_revision.revision_id, self.content_revision.revision_type)
|
995
|
|
- return '%s%s' % (left_side, self.provider.transform_to_display(self.content_revision.file_name))
|
|
997
|
+ return '%s%s' % (left_side, transform_to_display(self.content_revision.file_name))
|
996
|
998
|
|
997
|
999
|
def getContent(self):
|
998
|
1000
|
filestream = compat.BytesIO()
|
|
@@ -1081,7 +1083,7 @@ class HistoryOtherFile(OtherFile):
|
1081
|
1083
|
|
1082
|
1084
|
def getDisplayName(self) -> str:
|
1083
|
1085
|
left_side = '(%d - %s) ' % (self.content_revision.revision_id, self.content_revision.revision_type)
|
1084
|
|
- return '%s%s' % (left_side, self.provider.transform_to_display(self.content_revision.get_label()))
|
|
1086
|
+ return '%s%s' % (left_side, transform_to_display(self.content_revision.get_label()))
|
1085
|
1087
|
|
1086
|
1088
|
def getContent(self):
|
1087
|
1089
|
filestream = compat.BytesIO()
|