Browse Source

Fix unfilled params in methods for webdav

Guénaël Muller 6 years ago
parent
commit
b2e2a68aca
1 changed files with 142 additions and 29 deletions
  1. 142 29
      tracim/lib/webdav/resources.py

+ 142 - 29
tracim/lib/webdav/resources.py View File

163
                     environ=self.environ,
163
                     environ=self.environ,
164
                     workspace=workspace,
164
                     workspace=workspace,
165
                     user=self.user,
165
                     user=self.user,
166
-                    session=self.session)
166
+                    session=self.session,
167
+                )
167
             )
168
             )
168
 
169
 
169
         return members
170
         return members
293
         transaction.commit()
294
         transaction.commit()
294
 
295
 
295
         return Folder('%s/%s' % (self.path, transform_to_display(label)),
296
         return Folder('%s/%s' % (self.path, transform_to_display(label)),
296
-                      self.environ, folder,
297
-                      self.workspace)
297
+                      self.environ,
298
+                      content=folder,
299
+                      session=self.session,
300
+                      user=self.user,
301
+                      workspace=self.workspace,
302
+                      )
298
 
303
 
299
     def delete(self):
304
     def delete(self):
300
         """For now, it is not possible to delete a workspace through the webdav client."""
305
         """For now, it is not possible to delete a workspace through the webdav client."""
337
                         environ=self.environ,
342
                         environ=self.environ,
338
                         content=content,
343
                         content=content,
339
                         user=self.user,
344
                         user=self.user,
340
-                        session=self.session
345
+                        session=self.session,
341
                     )
346
                     )
342
                 )
347
                 )
343
             else:
348
             else:
344
                 self._file_count += 1
349
                 self._file_count += 1
345
-                members.append(OtherFile(content_path, self.environ, content))
350
+                members.append(
351
+                    OtherFile(
352
+                        content_path,
353
+                        self.environ,
354
+                        content,
355
+                        session=self.session,
356
+                        user=self.user,
357
+                    ))
346
 
358
 
347
         if self._file_count > 0 and self.provider.show_history():
359
         if self._file_count > 0 and self.provider.show_history():
348
             members.append(
360
             members.append(
351
                     environ=self.environ,
363
                     environ=self.environ,
352
                     content=self.content,
364
                     content=self.content,
353
                     workspace=self.workspace,
365
                     workspace=self.workspace,
354
-                    type=HistoryType.Standard
366
+                    type=HistoryType.Standard,
367
+                    session=self.session,
368
+                    user=self.user,
355
                 )
369
                 )
356
             )
370
             )
357
 
371
 
361
                     path=self.path + '/' + ".deleted",
375
                     path=self.path + '/' + ".deleted",
362
                     environ=self.environ,
376
                     environ=self.environ,
363
                     content=self.content,
377
                     content=self.content,
364
-                    workspace=self.workspace
378
+                    workspace=self.workspace,
379
+                    session=self.session,
380
+                    user=self.user,
365
                 )
381
                 )
366
             )
382
             )
367
 
383
 
371
                     path=self.path + '/' + ".archived",
387
                     path=self.path + '/' + ".archived",
372
                     environ=self.environ,
388
                     environ=self.environ,
373
                     content=self.content,
389
                     content=self.content,
374
-                    workspace=self.workspace
390
+                    workspace=self.workspace,
391
+                    user=self.user,
392
+                    session=self.session,
375
                 )
393
                 )
376
             )
394
             )
377
 
395
 
482
 
500
 
483
     def move_folder(self, destpath):
501
     def move_folder(self, destpath):
484
 
502
 
485
-        workspace_api = WorkspaceApi(self.user)
503
+        workspace_api = WorkspaceApi(
504
+            current_user=self.user,
505
+            session=self.session,
506
+        )
486
         workspace = self.provider.get_workspace_from_path(
507
         workspace = self.provider.get_workspace_from_path(
487
             normpath(destpath), workspace_api
508
             normpath(destpath), workspace_api
488
         )
509
         )
493
             workspace
514
             workspace
494
         )
515
         )
495
 
516
 
496
-        with new_revision(self.content):
517
+        with new_revision(
518
+            content=self.content,
519
+            tm=transaction.manager,
520
+            session=self.session,
521
+        ):
497
             if basename(destpath) != self.getDisplayName():
522
             if basename(destpath) != self.getDisplayName():
498
                 self.content_api.update_content(self.content, transform_to_bdd(basename(destpath)))
523
                 self.content_api.update_content(self.content, transform_to_bdd(basename(destpath)))
499
                 self.content_api.save(self.content)
524
                 self.content_api.save(self.content)
568
                     environ=self.environ,
593
                     environ=self.environ,
569
                     content=self.content,
594
                     content=self.content,
570
                     workspace=self.workspace,
595
                     workspace=self.workspace,
571
-                    type=HistoryType.Standard
596
+                    type=HistoryType.Standard,
597
+                    user=self.user,
598
+                    session=self.session,
572
                 )
599
                 )
573
             )
600
             )
574
 
601
 
578
                     path=self.path + '/' + ".deleted",
605
                     path=self.path + '/' + ".deleted",
579
                     environ=self.environ,
606
                     environ=self.environ,
580
                     content=self.content,
607
                     content=self.content,
581
-                    workspace=self.workspace
608
+                    workspace=self.workspace,
609
+                    user=self.user,
610
+                    session=self.session,
582
                 )
611
                 )
583
             )
612
             )
584
 
613
 
588
                     path=self.path + '/' + ".archived",
617
                     path=self.path + '/' + ".archived",
589
                     environ=self.environ,
618
                     environ=self.environ,
590
                     content=self.content,
619
                     content=self.content,
591
-                    workspace=self.workspace
620
+                    workspace=self.workspace,
621
+                    user=self.user,
622
+                    session=self.session,
592
                 )
623
                 )
593
             )
624
             )
594
 
625
 
595
         return members
626
         return members
596
 
627
 
628
+# TODO - G.M - 02-05-2018 - Check these object (History/Deleted/Archived Folder)
629
+# Those object are now not in used by tracim and also not tested,
630
+
597
 
631
 
598
 class HistoryFolder(Folder):
632
 class HistoryFolder(Folder):
599
     """
633
     """
625
         self.content_api = ContentApi(
659
         self.content_api = ContentApi(
626
             current_user=self.user,
660
             current_user=self.user,
627
             show_archived=self._is_archived,
661
             show_archived=self._is_archived,
628
-            show_deleted=self._is_deleted
662
+            show_deleted=self._is_deleted,
663
+            session=self.session,
664
+            config=self.provider.app_config,
629
         )
665
         )
630
 
666
 
631
     def __repr__(self) -> str:
667
     def __repr__(self) -> str:
649
         return HistoryFileFolder(
685
         return HistoryFileFolder(
650
             path='%s/%s' % (self.path, content.get_label_as_file()),
686
             path='%s/%s' % (self.path, content.get_label_as_file()),
651
             environ=self.environ,
687
             environ=self.environ,
652
-            content=content)
688
+            content=content,
689
+            session=self.session,
690
+            user=self.user,
691
+        )
653
 
692
 
654
     def getMemberNames(self) -> [str]:
693
     def getMemberNames(self) -> [str]:
655
         ret = []
694
         ret = []
695
                 members.append(HistoryFileFolder(
734
                 members.append(HistoryFileFolder(
696
                     path='%s/%s' % (self.path, content.get_label_as_file()),
735
                     path='%s/%s' % (self.path, content.get_label_as_file()),
697
                     environ=self.environ,
736
                     environ=self.environ,
698
-                    content=content))
737
+                    content=content,
738
+                    user=self.user,
739
+                    session=self.session,
740
+                ))
699
 
741
 
700
         return members
742
         return members
701
 
743
 
780
                 content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
822
                 content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
781
 
823
 
782
                 if content.type == ContentType.Folder:
824
                 if content.type == ContentType.Folder:
783
-                    members.append(Folder(content_path, self.environ, self.workspace, content))
825
+                    members.append(
826
+                        Folder(
827
+                            content_path,
828
+                            self.environ,
829
+                            self.workspace,
830
+                            content,
831
+                            user=self.user,
832
+                            session=self.session,
833
+                        ))
784
                 elif content.type == ContentType.File:
834
                 elif content.type == ContentType.File:
785
                     self._file_count += 1
835
                     self._file_count += 1
786
-                    members.append(File(content_path, self.environ, content))
836
+                    members.append(
837
+                        File(
838
+                            content_path,
839
+                            self.environ,
840
+                            content,
841
+                            user=self.user,
842
+                            session=self.session,
843
+                        )
844
+                    )
787
                 else:
845
                 else:
788
                     self._file_count += 1
846
                     self._file_count += 1
789
-                    members.append(OtherFile(content_path, self.environ, content))
847
+                    members.append(
848
+                        OtherFile(
849
+                            content_path,
850
+                            self.environ,
851
+                            content,
852
+                            user=self.user,
853
+                            session=self.session,
854
+                    ))
790
 
855
 
791
         if self._file_count > 0 and self.provider.show_history():
856
         if self._file_count > 0 and self.provider.show_history():
792
             members.append(
857
             members.append(
797
                     workspace=self.workspace,
862
                     workspace=self.workspace,
798
                     user=self.user,
863
                     user=self.user,
799
                     type=HistoryType.Standard,
864
                     type=HistoryType.Standard,
865
+                    session=self.session,
800
                 )
866
                 )
801
             )
867
             )
802
 
868
 
877
                 content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
943
                 content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
878
 
944
 
879
                 if content.type == ContentType.Folder:
945
                 if content.type == ContentType.Folder:
880
-                    members.append(Folder(content_path, self.environ, self.workspace, content))
946
+                    members.append(
947
+                        Folder(
948
+                            content_path,
949
+                            self.environ,
950
+                            self.workspace,
951
+                            content,
952
+                            user=self.user,
953
+                            session=self.session,
954
+                        ))
881
                 elif content.type == ContentType.File:
955
                 elif content.type == ContentType.File:
882
                     self._file_count += 1
956
                     self._file_count += 1
883
-                    members.append(File(content_path, self.environ, content))
957
+                    members.append(
958
+                        File(
959
+                            content_path,
960
+                            self.environ,
961
+                            content,
962
+                            user=self.user,
963
+                            session=self.session,
964
+                        ))
884
                 else:
965
                 else:
885
                     self._file_count += 1
966
                     self._file_count += 1
886
-                    members.append(OtherFile(content_path, self.environ, content))
967
+                    members.append(
968
+                        OtherFile(
969
+                            content_path,
970
+                            self.environ,
971
+                            content,
972
+                            user=self.user,
973
+                            session=self.session,
974
+                        ))
887
 
975
 
888
         if self._file_count > 0 and self.provider.show_history():
976
         if self._file_count > 0 and self.provider.show_history():
889
             members.append(
977
             members.append(
893
                     content=self.content,
981
                     content=self.content,
894
                     workspace=self.workspace,
982
                     workspace=self.workspace,
895
                     user=self.user,
983
                     user=self.user,
896
-                    type=HistoryType.Standard
984
+                    type=HistoryType.Standard,
985
+                    session=self.session,
897
                 )
986
                 )
898
             )
987
             )
899
 
988
 
955
                 path='%s%s' % (left_side, transform_to_display(revision.file_name)),
1044
                 path='%s%s' % (left_side, transform_to_display(revision.file_name)),
956
                 environ=self.environ,
1045
                 environ=self.environ,
957
                 content=self.content,
1046
                 content=self.content,
958
-                content_revision=revision)
1047
+                content_revision=revision,
1048
+                session=self.session,
1049
+                user=self.user,
1050
+            )
959
         else:
1051
         else:
960
             return HistoryOtherFile(
1052
             return HistoryOtherFile(
961
                 path='%s%s' % (left_side, transform_to_display(revision.get_label_as_file())),
1053
                 path='%s%s' % (left_side, transform_to_display(revision.get_label_as_file())),
962
                 environ=self.environ,
1054
                 environ=self.environ,
963
                 content=self.content,
1055
                 content=self.content,
964
-                content_revision=revision)
1056
+                content_revision=revision,
1057
+                session=self.session,
1058
+                user=self.user,
1059
+            )
965
 
1060
 
966
     def getMemberList(self) -> [_DAVResource]:
1061
     def getMemberList(self) -> [_DAVResource]:
967
         members = []
1062
         members = []
975
                     path='%s%s' % (left_side, transform_to_display(content.file_name)),
1070
                     path='%s%s' % (left_side, transform_to_display(content.file_name)),
976
                     environ=self.environ,
1071
                     environ=self.environ,
977
                     content=self.content,
1072
                     content=self.content,
978
-                    content_revision=content)
1073
+                    content_revision=content,
1074
+                    user=self.user,
1075
+                    session=self.session,
1076
+                    )
979
                 )
1077
                 )
980
             else:
1078
             else:
981
                 members.append(HistoryOtherFile(
1079
                 members.append(HistoryOtherFile(
982
                     path='%s%s' % (left_side, transform_to_display(content.file_name)),
1080
                     path='%s%s' % (left_side, transform_to_display(content.file_name)),
983
                     environ=self.environ,
1081
                     environ=self.environ,
984
                     content=self.content,
1082
                     content=self.content,
985
-                    content_revision=content)
1083
+                    content_revision=content,
1084
+                    user=self.user,
1085
+                    session=self.session,
1086
+                    )
986
                 )
1087
                 )
987
 
1088
 
988
         return members
1089
         return members
1322
     """
1423
     """
1323
     A virtual resource corresponding to a specific tracim's revision's page and thread
1424
     A virtual resource corresponding to a specific tracim's revision's page and thread
1324
     """
1425
     """
1325
-    def __init__(self, path: str, environ: dict, content: Content, user:User, content_revision: ContentRevisionRO):
1326
-        super(HistoryOtherFile, self).__init__(path, environ, content, user=user, session=self.session)
1426
+    def __init__(self,
1427
+                 path: str,
1428
+                 environ: dict,
1429
+                 content: Content,
1430
+                 user:User,
1431
+                 content_revision: ContentRevisionRO,
1432
+                 session: Session):
1433
+        super(HistoryOtherFile, self).__init__(
1434
+            path,
1435
+            environ,
1436
+            content,
1437
+            user=user,
1438
+            session=session
1439
+        )
1327
         self.content_revision = content_revision
1440
         self.content_revision = content_revision
1328
         self.content_designed = self.design()
1441
         self.content_designed = self.design()
1329
 
1442