Browse Source

WebDAV dev fixes

Bastien Sevajol (Algoo) 8 years ago
parent
commit
1cea7641fd

+ 5 - 2
tracim/tracim/lib/content.py View File

@@ -316,7 +316,7 @@ class ContentApi(object):
316 316
 
317 317
         return result
318 318
 
319
-    def create(self, content_type: str, workspace: Workspace, parent: Content=None, label:str ='', is_temporary:bool =False, do_save=False) -> Content:
319
+    def create(self, content_type: str, workspace: Workspace, parent: Content=None, label:str ='', do_save=False, is_temporary: bool=False) -> Content:
320 320
         assert content_type in ContentType.allowed_types()
321 321
         content = Content()
322 322
         content.owner = self._user
@@ -457,7 +457,10 @@ class ContentApi(object):
457 457
         if content_type!=ContentType.Any:
458 458
             resultset = resultset.filter(Content.type==content_type)
459 459
 
460
-        resultset = resultset.filter(Content.parent_id==parent_id)
460
+        if parent_id:
461
+            resultset = resultset.filter(Content.parent_id==parent_id)
462
+        if parent_id is False:
463
+            resultset = resultset.filter(Content.parent_id == None)
461 464
 
462 465
         return resultset.all()
463 466
 

+ 5 - 5
tracim/tracim/lib/webdav/sql_resources.py View File

@@ -293,7 +293,7 @@ class Workspace(DAVCollection):
293 293
     def getMemberList(self) -> [_DAVResource]:
294 294
         members = []
295 295
 
296
-        children = self.content_api.get_all(None, ContentType.Any, self.workspace)
296
+        children = self.content_api.get_all(False, ContentType.Any, self.workspace)
297 297
 
298 298
         for content in children:
299 299
             content_path = '%s/%s' % (self.path, self.provider.transform_to_display(content.get_label()))
@@ -582,7 +582,7 @@ class HistoryFolder(Folder):
582 582
         if self.content:
583 583
             children = self.content.children
584 584
         else:
585
-            children = self.content_api.get_all(None, ContentType.Any, self.workspace)
585
+            children = self.content_api.get_all(False, ContentType.Any, self.workspace)
586 586
         
587 587
         for content in children:
588 588
             if content.is_archived == self._is_archived and content.is_deleted == self._is_deleted:
@@ -634,7 +634,7 @@ class DeletedFolder(HistoryFolder):
634 634
         if self.content:
635 635
             children = self.content.children
636 636
         else:
637
-            children = self.content_api.get_all(None, ContentType.Any, self.workspace)
637
+            children = self.content_api.get_all(False, ContentType.Any, self.workspace)
638 638
 
639 639
         for content in children:
640 640
             if content.is_deleted:
@@ -651,7 +651,7 @@ class DeletedFolder(HistoryFolder):
651 651
         if self.content:
652 652
             children = self.content.children
653 653
         else:
654
-            children = self.content_api.get_all(None, ContentType.Any, self.workspace)
654
+            children = self.content_api.get_all(False, ContentType.Any, self.workspace)
655 655
 
656 656
         for content in children:
657 657
             if content.is_deleted:
@@ -731,7 +731,7 @@ class ArchivedFolder(HistoryFolder):
731 731
         if self.content:
732 732
             children = self.content.children
733 733
         else:
734
-            children = self.content_api.get_all(None, ContentType.Any, self.workspace)
734
+            children = self.content_api.get_all(False, ContentType.Any, self.workspace)
735 735
 
736 736
         for content in children:
737 737
             if content.is_archived:

+ 1 - 1
tracim/tracim/model/data.py View File

@@ -549,7 +549,7 @@ class ContentRevisionRO(DeclarativeBase):
549 549
     _cloned_columns = (
550 550
         'content_id', 'created', 'description', 'file_content', 'file_mimetype', 'file_name', 'is_archived',
551 551
         'is_deleted', 'label', 'node', 'owner', 'owner_id', 'parent', 'parent_id', 'properties', 'revision_type',
552
-        'status', 'type', 'updated', 'workspace', 'workspace_id',
552
+        'status', 'type', 'updated', 'workspace', 'workspace_id', 'is_temporary',
553 553
     )
554 554
 
555 555
     # Read by must be used like this:

+ 21 - 3
tracim/tracim/tests/library/test_content_api.py View File

@@ -244,9 +244,27 @@ class TestContentApi(BaseTest, TestStandard):
244 244
                                                         save_now=True)
245 245
 
246 246
         api = ContentApi(user)
247
-        item = api.create(ContentType.Folder, workspace, None, 'parent', True)
248
-        item2 = api.create(ContentType.File, workspace, item, 'file1', True)
249
-        item3 = api.create(ContentType.File, workspace, None, 'file2', True)
247
+        item = api.create(
248
+            ContentType.Folder,
249
+            workspace,
250
+            None,
251
+            'parent',
252
+            do_save=True,
253
+        )
254
+        item2 = api.create(
255
+            ContentType.File,
256
+            workspace,
257
+            item,
258
+            'file1',
259
+            do_save=True,
260
+        )
261
+        item3 = api.create(
262
+            ContentType.File,
263
+            workspace,
264
+            None,
265
+            'file2',
266
+            do_save=True,
267
+        )
250 268
         parent_id = item.content_id
251 269
         child_id = item2.content_id
252 270
         uid = user.user_id