Browse Source

workspace and parent params needed for move endpoint + root is same as parent_id is None/null

Guénaël Muller 6 years ago
parent
commit
7bb1783d1f

+ 1 - 3
tracim/models/context_models.py View File

292
     @property
292
     @property
293
     def parent_id(self) -> int:
293
     def parent_id(self) -> int:
294
         """
294
         """
295
-        Return parent_id of the content, if it doesn't exist return 0
295
+        Return parent_id of the content
296
         """
296
         """
297
-        if not self.content.parent_id:
298
-            return 0
299
         return self.content.parent_id
297
         return self.content.parent_id
300
 
298
 
301
     @property
299
     @property

+ 7 - 4
tracim/tests/functional/test_workspaces.py View File

786
         )
786
         )
787
         params = {
787
         params = {
788
             'new_parent_id': '4',  # Salads
788
             'new_parent_id': '4',  # Salads
789
+            'new_workspace_id': '2',
789
         }
790
         }
790
         params_folder1 = {
791
         params_folder1 = {
791
             'parent_id': 3,
792
             'parent_id': 3,
833
             )
834
             )
834
         )
835
         )
835
         params = {
836
         params = {
836
-            'new_parent_id': '0',  # root
837
+            'new_parent_id': None,  # root
838
+            'new_workspace_id': 2,
837
         }
839
         }
838
         params_folder1 = {
840
         params_folder1 = {
839
             'parent_id': 3,
841
             'parent_id': 3,
862
         assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
864
         assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
863
         assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
865
         assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
864
         assert res.json_body
866
         assert res.json_body
865
-        assert res.json_body['parent_id'] == 0
867
+        assert res.json_body['parent_id'] is None
866
         assert res.json_body['content_id'] == 8
868
         assert res.json_body['content_id'] == 8
867
         assert res.json_body['workspace_id'] == 2
869
         assert res.json_body['workspace_id'] == 2
868
 
870
 
931
         )
933
         )
932
         params = {
934
         params = {
933
             'new_parent_id': '2',  # Menus
935
             'new_parent_id': '2',  # Menus
936
+            'new_workspace_id': '1',
934
         }
937
         }
935
         params_folder1 = {
938
         params_folder1 = {
936
             'parent_id': 3,
939
             'parent_id': 3,
978
             )
981
             )
979
         )
982
         )
980
         params = {
983
         params = {
981
-            'new_parent_id': '0', # root
984
+            'new_parent_id': None,  # root
982
             'new_workspace_id': '1',
985
             'new_workspace_id': '1',
983
         }
986
         }
984
         params_folder1 = {
987
         params_folder1 = {
1008
         assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
1011
         assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
1009
         assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
1012
         assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
1010
         assert res.json_body
1013
         assert res.json_body
1011
-        assert res.json_body['parent_id'] == 0
1014
+        assert res.json_body['parent_id'] is None
1012
         assert res.json_body['content_id'] == 8
1015
         assert res.json_body['content_id'] == 8
1013
         assert res.json_body['workspace_id'] == 1
1016
         assert res.json_body['workspace_id'] == 1
1014
 
1017
 

+ 4 - 3
tracim/views/core_api/schemas.py View File

288
     # (the user must be content manager of both workspaces)
288
     # (the user must be content manager of both workspaces)
289
     new_parent_id = marshmallow.fields.Int(
289
     new_parent_id = marshmallow.fields.Int(
290
         example=42,
290
         example=42,
291
-        description='id of the new parent content id.'
291
+        description='id of the new parent content id.',
292
+        allow_none=True,
293
+        required=True,
292
     )
294
     )
293
     new_workspace_id = marshmallow.fields.Int(
295
     new_workspace_id = marshmallow.fields.Int(
294
         example=2,
296
         example=2,
295
         description='id of the new workspace id.',
297
         description='id of the new workspace id.',
296
-        allow_none=True,
297
-        default=None,
298
+        required=True
298
     )
299
     )
299
 
300
 
300
     @post_load
301
     @post_load