|
@@ -54,7 +54,7 @@ class ManageActions(object):
|
54
|
54
|
try:
|
55
|
55
|
# When undeleting/unarchiving we except a content with the new name to not exist, thus if we
|
56
|
56
|
# don't get an error and the database request send back a result, we stop the action
|
57
|
|
- self.content_api.get_one_by_label_and_parent(self._new_name, self.content.parent, self.content.workspace)
|
|
57
|
+ self.content_api.get_one_by_label_and_parent(self._new_name, self.content.parent)
|
58
|
58
|
raise DAVError(HTTP_FORBIDDEN)
|
59
|
59
|
except NoResultFound:
|
60
|
60
|
with new_revision(self.content):
|
|
@@ -69,7 +69,7 @@ class ManageActions(object):
|
69
|
69
|
Will create the new name, either by adding '- deleted the [date]' after the name when archiving/deleting or
|
70
|
70
|
removing this string when undeleting/unarchiving
|
71
|
71
|
"""
|
72
|
|
- new_name = self.content.get_label()
|
|
72
|
+ new_name = self.content.get_label_as_file()
|
73
|
73
|
extension = ''
|
74
|
74
|
|
75
|
75
|
# if the content has no label, the last .ext is important
|
|
@@ -219,7 +219,7 @@ class Workspace(DAVCollection):
|
219
|
219
|
# the purpose is to display .history only if there's at least one content's type that has a history
|
220
|
220
|
if content.type != ContentType.Folder:
|
221
|
221
|
self._file_count += 1
|
222
|
|
- retlist.append(content.get_label())
|
|
222
|
+ retlist.append(content.get_label_as_file())
|
223
|
223
|
|
224
|
224
|
return retlist
|
225
|
225
|
|
|
@@ -310,7 +310,7 @@ class Workspace(DAVCollection):
|
310
|
310
|
children = self.content_api.get_all(False, ContentType.Any, self.workspace)
|
311
|
311
|
|
312
|
312
|
for content in children:
|
313
|
|
- content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
|
313
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
|
314
|
314
|
|
315
|
315
|
if content.type == ContentType.Folder:
|
316
|
316
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -374,7 +374,7 @@ class Folder(Workspace):
|
374
|
374
|
return mktime(self.content.created.timetuple())
|
375
|
375
|
|
376
|
376
|
def getDisplayName(self) -> str:
|
377
|
|
- return transform_to_display(self.content.get_label())
|
|
377
|
+ return transform_to_display(self.content.get_label_as_file())
|
378
|
378
|
|
379
|
379
|
def getLastModified(self) -> float:
|
380
|
380
|
return mktime(self.content.updated.timetuple())
|
|
@@ -472,7 +472,7 @@ class Folder(Workspace):
|
472
|
472
|
)
|
473
|
473
|
|
474
|
474
|
for content in visible_children:
|
475
|
|
- content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
|
475
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
|
476
|
476
|
|
477
|
477
|
if content.type == ContentType.Folder:
|
478
|
478
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -555,7 +555,7 @@ class HistoryFolder(Folder):
|
555
|
555
|
)
|
556
|
556
|
|
557
|
557
|
return HistoryFileFolder(
|
558
|
|
- path='%s/%s' % (self.path, content.get_label()),
|
|
558
|
+ path='%s/%s' % (self.path, content.get_label_as_file()),
|
559
|
559
|
environ=self.environ,
|
560
|
560
|
content=content)
|
561
|
561
|
|
|
@@ -568,7 +568,7 @@ class HistoryFolder(Folder):
|
568
|
568
|
self._is_deleted and content.is_deleted or
|
569
|
569
|
not (content.is_archived or self._is_archived or content.is_deleted or self._is_deleted))\
|
570
|
570
|
and content.type != ContentType.Folder:
|
571
|
|
- ret.append(content.get_label())
|
|
571
|
+ ret.append(content.get_label_as_file())
|
572
|
572
|
|
573
|
573
|
return ret
|
574
|
574
|
|
|
@@ -601,7 +601,7 @@ class HistoryFolder(Folder):
|
601
|
601
|
for content in children:
|
602
|
602
|
if content.is_archived == self._is_archived and content.is_deleted == self._is_deleted:
|
603
|
603
|
members.append(HistoryFileFolder(
|
604
|
|
- path='%s/%s' % (self.path, content.get_label()),
|
|
604
|
+ path='%s/%s' % (self.path, content.get_label_as_file()),
|
605
|
605
|
environ=self.environ,
|
606
|
606
|
content=content))
|
607
|
607
|
|
|
@@ -638,7 +638,7 @@ class DeletedFolder(HistoryFolder):
|
638
|
638
|
)
|
639
|
639
|
|
640
|
640
|
return self.provider.getResourceInst(
|
641
|
|
- path='%s/%s' % (self.path, transform_to_display(content.get_label())),
|
|
641
|
+ path='%s/%s' % (self.path, transform_to_display(content.get_label_as_file())),
|
642
|
642
|
environ=self.environ
|
643
|
643
|
)
|
644
|
644
|
|
|
@@ -652,7 +652,7 @@ class DeletedFolder(HistoryFolder):
|
652
|
652
|
|
653
|
653
|
for content in children:
|
654
|
654
|
if content.is_deleted:
|
655
|
|
- retlist.append(content.get_label())
|
|
655
|
+ retlist.append(content.get_label_as_file())
|
656
|
656
|
|
657
|
657
|
if content.type != ContentType.Folder:
|
658
|
658
|
self._file_count += 1
|
|
@@ -669,7 +669,7 @@ class DeletedFolder(HistoryFolder):
|
669
|
669
|
|
670
|
670
|
for content in children:
|
671
|
671
|
if content.is_deleted:
|
672
|
|
- content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
|
672
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
|
673
|
673
|
|
674
|
674
|
if content.type == ContentType.Folder:
|
675
|
675
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -723,7 +723,7 @@ class ArchivedFolder(HistoryFolder):
|
723
|
723
|
)
|
724
|
724
|
|
725
|
725
|
return self.provider.getResourceInst(
|
726
|
|
- path=self.path + '/' + transform_to_display(content.get_label()),
|
|
726
|
+ path=self.path + '/' + transform_to_display(content.get_label_as_file()),
|
727
|
727
|
environ=self.environ
|
728
|
728
|
)
|
729
|
729
|
|
|
@@ -732,7 +732,7 @@ class ArchivedFolder(HistoryFolder):
|
732
|
732
|
|
733
|
733
|
for content in self.content_api.get_all_with_filter(
|
734
|
734
|
self.content if self.content is None else self.content.id, ContentType.Any):
|
735
|
|
- retlist.append(content.get_label())
|
|
735
|
+ retlist.append(content.get_label_as_file())
|
736
|
736
|
|
737
|
737
|
if content.type != ContentType.Folder:
|
738
|
738
|
self._file_count += 1
|
|
@@ -749,7 +749,7 @@ class ArchivedFolder(HistoryFolder):
|
749
|
749
|
|
750
|
750
|
for content in children:
|
751
|
751
|
if content.is_archived:
|
752
|
|
- content_path = '%s/%s' % (self.path, transform_to_display(content.get_label()))
|
|
752
|
+ content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
|
753
|
753
|
|
754
|
754
|
if content.type == ContentType.Folder:
|
755
|
755
|
members.append(Folder(content_path, self.environ, self.workspace, content))
|
|
@@ -786,7 +786,7 @@ class HistoryFileFolder(HistoryFolder):
|
786
|
786
|
return "<DAVCollection: HistoryFileFolder (%s)" % self.content.file_name
|
787
|
787
|
|
788
|
788
|
def getDisplayName(self) -> str:
|
789
|
|
- return self.content.get_label()
|
|
789
|
+ return self.content.get_label_as_file()
|
790
|
790
|
|
791
|
791
|
def createCollection(self, name):
|
792
|
792
|
raise DAVError(HTTP_FORBIDDEN)
|
|
@@ -817,7 +817,7 @@ class HistoryFileFolder(HistoryFolder):
|
817
|
817
|
content_revision=revision)
|
818
|
818
|
else:
|
819
|
819
|
return HistoryOtherFile(
|
820
|
|
- path='%s%s' % (left_side, transform_to_display(revision.get_label())),
|
|
820
|
+ path='%s%s' % (left_side, transform_to_display(revision.get_label_as_file())),
|
821
|
821
|
environ=self.environ,
|
822
|
822
|
content=self.content,
|
823
|
823
|
content_revision=revision)
|
|
@@ -862,15 +862,6 @@ class File(DAVNonCollection):
|
862
|
862
|
# but i wasn't able to set this property so you'll have to look into it >.>
|
863
|
863
|
# self.setPropertyValue('Win32FileAttributes', '00000021')
|
864
|
864
|
|
865
|
|
- def getPreferredPath(self):
|
866
|
|
- fix_txt = '.txt' if self.getContentType() == 'text/plain' else mimetypes.guess_extension(self.getContentType())
|
867
|
|
- if not fix_txt:
|
868
|
|
- fix_txt = ''
|
869
|
|
- if self.content and self.path and (self.content.label == '' or self.path.endswith(fix_txt)):
|
870
|
|
- return self.path
|
871
|
|
- else:
|
872
|
|
- return self.path + fix_txt
|
873
|
|
-
|
874
|
865
|
def __repr__(self) -> str:
|
875
|
866
|
return "<DAVNonCollection: File (%d)>" % self.content.revision_id
|
876
|
867
|
|
|
@@ -884,7 +875,7 @@ class File(DAVNonCollection):
|
884
|
875
|
return mktime(self.content.created.timetuple())
|
885
|
876
|
|
886
|
877
|
def getDisplayName(self) -> str:
|
887
|
|
- return self.content.get_label()
|
|
878
|
+ return self.content.file_name
|
888
|
879
|
|
889
|
880
|
def getLastModified(self) -> float:
|
890
|
881
|
return mktime(self.content.updated.timetuple())
|
|
@@ -900,7 +891,7 @@ class File(DAVNonCollection):
|
900
|
891
|
return FakeFileStream(
|
901
|
892
|
content=self.content,
|
902
|
893
|
content_api=self.content_api,
|
903
|
|
- file_name=self.content.get_label(),
|
|
894
|
+ file_name=self.content.get_label_as_file(),
|
904
|
895
|
workspace=self.content.workspace,
|
905
|
896
|
path=self.path
|
906
|
897
|
)
|
|
@@ -1048,7 +1039,7 @@ class OtherFile(File):
|
1048
|
1039
|
self.path += '.html'
|
1049
|
1040
|
|
1050
|
1041
|
def getDisplayName(self) -> str:
|
1051
|
|
- return self.content.get_label()
|
|
1042
|
+ return self.content.get_label_as_file()
|
1052
|
1043
|
|
1053
|
1044
|
def getPreferredPath(self):
|
1054
|
1045
|
return self.path
|
|
@@ -1094,7 +1085,7 @@ class HistoryOtherFile(OtherFile):
|
1094
|
1085
|
|
1095
|
1086
|
def getDisplayName(self) -> str:
|
1096
|
1087
|
left_side = '(%d - %s) ' % (self.content_revision.revision_id, self.content_revision.revision_type)
|
1097
|
|
- return '%s%s' % (left_side, transform_to_display(self.content_revision.get_label()))
|
|
1088
|
+ return '%s%s' % (left_side, transform_to_display(self.content_revision.get_label_as_file()))
|
1098
|
1089
|
|
1099
|
1090
|
def getContent(self):
|
1100
|
1091
|
filestream = compat.BytesIO()
|