Browse Source

WebDAV dev fixes

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

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

316
 
316
 
317
         return result
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
         assert content_type in ContentType.allowed_types()
320
         assert content_type in ContentType.allowed_types()
321
         content = Content()
321
         content = Content()
322
         content.owner = self._user
322
         content.owner = self._user
457
         if content_type!=ContentType.Any:
457
         if content_type!=ContentType.Any:
458
             resultset = resultset.filter(Content.type==content_type)
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
         return resultset.all()
465
         return resultset.all()
463
 
466
 

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

293
     def getMemberList(self) -> [_DAVResource]:
293
     def getMemberList(self) -> [_DAVResource]:
294
         members = []
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
         for content in children:
298
         for content in children:
299
             content_path = '%s/%s' % (self.path, self.provider.transform_to_display(content.get_label()))
299
             content_path = '%s/%s' % (self.path, self.provider.transform_to_display(content.get_label()))
582
         if self.content:
582
         if self.content:
583
             children = self.content.children
583
             children = self.content.children
584
         else:
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
         for content in children:
587
         for content in children:
588
             if content.is_archived == self._is_archived and content.is_deleted == self._is_deleted:
588
             if content.is_archived == self._is_archived and content.is_deleted == self._is_deleted:
634
         if self.content:
634
         if self.content:
635
             children = self.content.children
635
             children = self.content.children
636
         else:
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
         for content in children:
639
         for content in children:
640
             if content.is_deleted:
640
             if content.is_deleted:
651
         if self.content:
651
         if self.content:
652
             children = self.content.children
652
             children = self.content.children
653
         else:
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
         for content in children:
656
         for content in children:
657
             if content.is_deleted:
657
             if content.is_deleted:
731
         if self.content:
731
         if self.content:
732
             children = self.content.children
732
             children = self.content.children
733
         else:
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
         for content in children:
736
         for content in children:
737
             if content.is_archived:
737
             if content.is_archived:

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

549
     _cloned_columns = (
549
     _cloned_columns = (
550
         'content_id', 'created', 'description', 'file_content', 'file_mimetype', 'file_name', 'is_archived',
550
         'content_id', 'created', 'description', 'file_content', 'file_mimetype', 'file_name', 'is_archived',
551
         'is_deleted', 'label', 'node', 'owner', 'owner_id', 'parent', 'parent_id', 'properties', 'revision_type',
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
     # Read by must be used like this:
555
     # Read by must be used like this:

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

244
                                                         save_now=True)
244
                                                         save_now=True)
245
 
245
 
246
         api = ContentApi(user)
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
         parent_id = item.content_id
268
         parent_id = item.content_id
251
         child_id = item2.content_id
269
         child_id = item2.content_id
252
         uid = user.user_id
270
         uid = user.user_id