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,10 +292,8 @@ class ContentInContext(object):
292 292
     @property
293 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 297
         return self.content.parent_id
300 298
 
301 299
     @property

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

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

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

@@ -288,13 +288,14 @@ class ContentMoveSchema(marshmallow.Schema):
288 288
     # (the user must be content manager of both workspaces)
289 289
     new_parent_id = marshmallow.fields.Int(
290 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 295
     new_workspace_id = marshmallow.fields.Int(
294 296
         example=2,
295 297
         description='id of the new workspace id.',
296
-        allow_none=True,
297
-        default=None,
298
+        required=True
298 299
     )
299 300
 
300 301
     @post_load