Browse Source

Merge pull request #17 from tracim/fix/allow_to_get_archived_deleted_content

inkhey 6 years ago
parent
commit
3da7f59400
No account linked to committer's email

+ 4 - 0
backend/tracim_backend/lib/utils/request.py View File

@@ -229,6 +229,8 @@ class TracimRequest(Request):
229 229
             api = ContentApi(
230 230
                 current_user=user,
231 231
                 session=request.dbsession,
232
+                show_deleted=True,
233
+                show_archived=True,
232 234
                 config=request.registry.settings['CFG']
233 235
             )
234 236
             comment = api.get_one(
@@ -268,6 +270,8 @@ class TracimRequest(Request):
268 270
                 raise ContentNotFoundInTracimRequest('No content_id property found in request')  # nopep8
269 271
             api = ContentApi(
270 272
                 current_user=user,
273
+                show_deleted=True,
274
+                show_archived=True,
271 275
                 session=request.dbsession,
272 276
                 config=request.registry.settings['CFG']
273 277
             )

+ 48 - 0
backend/tracim_backend/tests/functional/test_contents.py View File

@@ -116,6 +116,54 @@ class TestHtmlDocuments(FunctionalTest):
116 116
         assert content['last_modifier']['avatar_url'] is None
117 117
         assert content['raw_content'] == '<p>To cook a great Tiramisu, you need many ingredients.</p>'  # nopep8
118 118
 
119
+    def test_api__get_html_document__ok_200__archived_content(self) -> None:
120
+        """
121
+        Get one html document of a content
122
+        """
123
+        self.testapp.authorization = (
124
+            'Basic',
125
+            (
126
+                'admin@admin.admin',
127
+                'admin@admin.admin'
128
+            )
129
+        )
130
+        res = self.testapp.put_json(
131
+            '/api/v2/workspaces/2/contents/6/archive',
132
+            status=204
133
+        )
134
+        res = self.testapp.get(
135
+            '/api/v2/workspaces/2/html-documents/6',
136
+            status=200
137
+        )
138
+        content = res.json_body
139
+        assert content['content_type'] == 'html-document'
140
+        assert content['content_id'] == 6
141
+        assert content['is_archived'] is True
142
+
143
+    def test_api__get_html_document__ok_200__deleted_content(self) -> None:
144
+        """
145
+        Get one html document of a content
146
+        """
147
+        self.testapp.authorization = (
148
+            'Basic',
149
+            (
150
+                'admin@admin.admin',
151
+                'admin@admin.admin'
152
+            )
153
+        )
154
+        res = self.testapp.put_json(
155
+            '/api/v2/workspaces/2/contents/6/delete',
156
+            status=204
157
+        )
158
+        res = self.testapp.get(
159
+            '/api/v2/workspaces/2/html-documents/6',
160
+            status=200
161
+        )
162
+        content = res.json_body
163
+        assert content['content_type'] == 'html-document'
164
+        assert content['content_id'] == 6
165
+        assert content['is_deleted'] is True
166
+
119 167
     def test_api__get_html_document__err_400__wrong_content_type(self) -> None:
120 168
         """
121 169
         Get one html document of a content content 7 is not html_document