Browse Source

rename vars: change case

Guénaël Muller 6 years ago
parent
commit
bde1f85f9b

+ 11 - 11
backend/tracim_backend/app_models/contents.py View File

2
 import typing
2
 import typing
3
 from enum import Enum
3
 from enum import Enum
4
 
4
 
5
-from tracim_backend.extensions import APP_LIST
5
+from tracim_backend.extensions import app_list
6
 from tracim_backend.exceptions import ContentTypeNotExist
6
 from tracim_backend.exceptions import ContentTypeNotExist
7
 from tracim_backend.exceptions import ContentStatusNotExist
7
 from tracim_backend.exceptions import ContentStatusNotExist
8
 
8
 
132
         self.allow_sub_content = allow_sub_content
132
         self.allow_sub_content = allow_sub_content
133
 
133
 
134
 
134
 
135
-thread_type = 'thread'
136
-file_type = 'file'
137
-markdownpluspage_type = 'markdownpage'
138
-html_documents_type = 'html-document'
139
-folder_type = 'folder'
135
+THREAD_TYPE = 'thread'
136
+FILE_TYPE = 'file'
137
+MARKDOWNPLUSPAGE_TYPE = 'markdownpage'
138
+HTML_DOCUMENTS_TYPE = 'html-document'
139
+FOLDER_TYPE = 'folder'
140
 
140
 
141
 # TODO - G.M - 31-05-2018 - Set Better Event params
141
 # TODO - G.M - 31-05-2018 - Set Better Event params
142
 event_type = ContentType(
142
 event_type = ContentType(
169
 
169
 
170
     @property
170
     @property
171
     def Folder(self):
171
     def Folder(self):
172
-        return self.get_one_by_slug(folder_type)
172
+        return self.get_one_by_slug(FOLDER_TYPE)
173
 
173
 
174
     @property
174
     @property
175
     def File(self):
175
     def File(self):
176
-        return self.get_one_by_slug(file_type)
176
+        return self.get_one_by_slug(FILE_TYPE)
177
 
177
 
178
     @property
178
     @property
179
     def Page(self):
179
     def Page(self):
180
-        return self.get_one_by_slug(html_documents_type)
180
+        return self.get_one_by_slug(HTML_DOCUMENTS_TYPE)
181
 
181
 
182
     @property
182
     @property
183
     def Thread(self):
183
     def Thread(self):
184
-        return self.get_one_by_slug(thread_type)
184
+        return self.get_one_by_slug(THREAD_TYPE)
185
 
185
 
186
     def __init__(self, app_list: typing.List['Application']):
186
     def __init__(self, app_list: typing.List['Application']):
187
         self.app_list = app_list
187
         self.app_list = app_list
255
         return properties_dict
255
         return properties_dict
256
 
256
 
257
 
257
 
258
-CONTENT_TYPES = ContentTypeList(APP_LIST)
258
+CONTENT_TYPES = ContentTypeList(app_list)

+ 3 - 3
backend/tracim_backend/app_models/validator.py View File

2
 from tracim_backend.app_models.contents import CONTENT_TYPES
2
 from tracim_backend.app_models.contents import CONTENT_TYPES
3
 
3
 
4
 # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
4
 # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
5
-# of tracim_backend, Be careful ALL_CONTENT_TYPES_VALIDATOR is a global_var !
5
+# of tracim_backend, Be careful all_content_types_validator is a global_var !
6
 
6
 
7
-ALL_CONTENT_TYPES_VALIDATOR = OneOf(choices=[])
7
+all_content_types_validator = OneOf(choices=[])
8
 
8
 
9
 
9
 
10
 def update_validators():
10
 def update_validators():
11
-    ALL_CONTENT_TYPES_VALIDATOR.choices = CONTENT_TYPES.endpoint_allowed_types_slug()  # nopep8
11
+    all_content_types_validator.choices = CONTENT_TYPES.endpoint_allowed_types_slug()  # nopep8

+ 5 - 5
backend/tracim_backend/config.py View File

5
 import os
5
 import os
6
 from paste.deploy.converters import asbool
6
 from paste.deploy.converters import asbool
7
 from tracim_backend.app_models.validator import update_validators
7
 from tracim_backend.app_models.validator import update_validators
8
-from tracim_backend.extensions import APP_LIST
8
+from tracim_backend.extensions import app_list
9
 from tracim_backend.lib.utils.logger import logger
9
 from tracim_backend.lib.utils.logger import logger
10
 from depot.manager import DepotManager
10
 from depot.manager import DepotManager
11
 from tracim_backend.app_models.applications import Application
11
 from tracim_backend.app_models.applications import Application
606
         )
606
         )
607
 
607
 
608
         # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
608
         # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
609
-        # of tracim_backend, Be careful APP_LIST is a global_var
610
-        APP_LIST.clear()
611
-        APP_LIST.extend([
609
+        # of tracim_backend, Be careful app_list is a global_var
610
+        app_list.clear()
611
+        app_list.extend([
612
             html_documents,
612
             html_documents,
613
             markdownpluspage,
613
             markdownpluspage,
614
             _file,
614
             _file,
617
             calendar,
617
             calendar,
618
         ])
618
         ])
619
         # TODO - G.M - 2018-08-08 - We need to update validators each time
619
         # TODO - G.M - 2018-08-08 - We need to update validators each time
620
-        # APP_LIST is updated.
620
+        # app_list is updated.
621
         update_validators()
621
         update_validators()
622
 
622
 
623
     class CST(object):
623
     class CST(object):

+ 6 - 6
backend/tracim_backend/extensions.py View File

4
 
4
 
5
 # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var of tracim_backend
5
 # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var of tracim_backend
6
 
6
 
7
-# INFO - G.M - 2018-08-08 - APP_LIST
8
-# APP_LIST is one of the few "global_val" in tracim_backend, with hapic
9
-# and ALL_CONTENT_TYPES_VALIDATOR.
7
+# INFO - G.M - 2018-08-08 - app_list
8
+# app_list is one of the few "global_val" in tracim_backend, with hapic
9
+# and all_content_types_validator.
10
 # The goal of this is to be able to get current list of loaded app.
10
 # The goal of this is to be able to get current list of loaded app.
11
 # List is empty until config load apps.
11
 # List is empty until config load apps.
12
-# If you need to update APP_LIST, think about updating Content validator like
13
-# ALL_CONTENT_TYPES_VALIDATOR , see  update_validators() method.
14
-APP_LIST = []
12
+# If you need to update app_list, think about updating Content validator like
13
+# all_content_types_validator , see  update_validators() method.
14
+app_list = []

+ 2 - 2
backend/tracim_backend/models/context_models.py View File

7
 from sqlalchemy.orm import Session
7
 from sqlalchemy.orm import Session
8
 from tracim_backend.config import CFG
8
 from tracim_backend.config import CFG
9
 from tracim_backend.config import PreviewDim
9
 from tracim_backend.config import PreviewDim
10
-from tracim_backend.extensions import APP_LIST
10
+from tracim_backend.extensions import app_list
11
 from tracim_backend.lib.core.application import ApplicationApi
11
 from tracim_backend.lib.core.application import ApplicationApi
12
 from tracim_backend.lib.utils.utils import get_root_frontend_url
12
 from tracim_backend.lib.utils.utils import get_root_frontend_url
13
 from tracim_backend.lib.utils.utils import password_generator
13
 from tracim_backend.lib.utils.utils import password_generator
495
         # list should be able to change (depending on activated/disabled
495
         # list should be able to change (depending on activated/disabled
496
         # apps)
496
         # apps)
497
         app_api = ApplicationApi(
497
         app_api = ApplicationApi(
498
-            APP_LIST
498
+            app_list
499
         )
499
         )
500
         return app_api.get_default_workspace_menu_entry(self.workspace)
500
         return app_api.get_default_workspace_menu_entry(self.workspace)
501
 
501
 

+ 2 - 2
backend/tracim_backend/tests/functional/test_system.py View File

1
 # coding=utf-8
1
 # coding=utf-8
2
 import transaction
2
 import transaction
3
-from tracim_backend.extensions import APP_LIST
3
+from tracim_backend.extensions import app_list
4
 from tracim_backend.lib.core.application import ApplicationApi
4
 from tracim_backend.lib.core.application import ApplicationApi
5
 from tracim_backend.models import get_tm_session
5
 from tracim_backend.models import get_tm_session
6
 from tracim_backend.app_models.contents import CONTENT_TYPES
6
 from tracim_backend.app_models.contents import CONTENT_TYPES
31
         res = res.json_body
31
         res = res.json_body
32
         dbsession = get_tm_session(self.session_factory, transaction.manager)
32
         dbsession = get_tm_session(self.session_factory, transaction.manager)
33
         app_api = ApplicationApi(
33
         app_api = ApplicationApi(
34
-            app_list=APP_LIST,
34
+            app_list=app_list,
35
         )
35
         )
36
         applications = app_api.get_all()
36
         applications = app_api.get_all()
37
         assert len(res) == len(applications)
37
         assert len(res) == len(applications)

+ 2 - 2
backend/tracim_backend/tests/functional/test_user.py View File

8
 import transaction
8
 import transaction
9
 
9
 
10
 from tracim_backend import models
10
 from tracim_backend import models
11
-from tracim_backend.extensions import APP_LIST
11
+from tracim_backend.extensions import app_list
12
 from tracim_backend.lib.core.application import ApplicationApi
12
 from tracim_backend.lib.core.application import ApplicationApi
13
 from tracim_backend.lib.core.content import ContentApi
13
 from tracim_backend.lib.core.content import ContentApi
14
 from tracim_backend.lib.core.user import UserApi
14
 from tracim_backend.lib.core.user import UserApi
2384
         )
2384
         )
2385
         workspace = workspace_api.get_one(1)
2385
         workspace = workspace_api.get_one(1)
2386
         app_api = ApplicationApi(
2386
         app_api = ApplicationApi(
2387
-            APP_LIST
2387
+            app_list
2388
         )
2388
         )
2389
 
2389
 
2390
         default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace)  # nope8
2390
         default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace)  # nope8

+ 3 - 3
backend/tracim_backend/tests/functional/test_workspaces.py View File

7
 from depot.io.utils import FileIntent
7
 from depot.io.utils import FileIntent
8
 
8
 
9
 from tracim_backend import models
9
 from tracim_backend import models
10
-from tracim_backend.extensions import APP_LIST
10
+from tracim_backend.extensions import app_list
11
 from tracim_backend.lib.core.application import ApplicationApi
11
 from tracim_backend.lib.core.application import ApplicationApi
12
 from tracim_backend.lib.core.content import ContentApi
12
 from tracim_backend.lib.core.content import ContentApi
13
 from tracim_backend.lib.core.group import GroupApi
13
 from tracim_backend.lib.core.group import GroupApi
46
         )
46
         )
47
         workspace = workspace_api.get_one(1)
47
         workspace = workspace_api.get_one(1)
48
         app_api = ApplicationApi(
48
         app_api = ApplicationApi(
49
-            APP_LIST
49
+            app_list
50
         )
50
         )
51
         default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace)  # nope8
51
         default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace)  # nope8
52
 
52
 
89
         )
89
         )
90
         workspace = workspace_api.get_one(1)
90
         workspace = workspace_api.get_one(1)
91
         app_api = ApplicationApi(
91
         app_api = ApplicationApi(
92
-            APP_LIST
92
+            app_list
93
         )
93
         )
94
         default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace)  # nope8
94
         default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace)  # nope8
95
 
95
 

+ 15 - 15
backend/tracim_backend/views/contents_api/file_controller.py View File

33
 from tracim_backend.models.context_models import ContentInContext
33
 from tracim_backend.models.context_models import ContentInContext
34
 from tracim_backend.models.context_models import RevisionInContext
34
 from tracim_backend.models.context_models import RevisionInContext
35
 from tracim_backend.app_models.contents import CONTENT_TYPES
35
 from tracim_backend.app_models.contents import CONTENT_TYPES
36
-from tracim_backend.app_models.contents import file_type
36
+from tracim_backend.app_models.contents import FILE_TYPE
37
 from tracim_backend.models.revision_protection import new_revision
37
 from tracim_backend.models.revision_protection import new_revision
38
 from tracim_backend.exceptions import EmptyLabelNotAllowed
38
 from tracim_backend.exceptions import EmptyLabelNotAllowed
39
 from tracim_backend.exceptions import PageOfPreviewNotFound
39
 from tracim_backend.exceptions import PageOfPreviewNotFound
50
     # File data
50
     # File data
51
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
51
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
52
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
52
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
53
-    @require_content_types([file_type])
53
+    @require_content_types([FILE_TYPE])
54
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
54
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
55
     # TODO - G.M - 2018-07-24 - Use hapic for input file
55
     # TODO - G.M - 2018-07-24 - Use hapic for input file
56
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
56
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
88
 
88
 
89
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
89
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
90
     @require_workspace_role(UserRoleInWorkspace.READER)
90
     @require_workspace_role(UserRoleInWorkspace.READER)
91
-    @require_content_types([file_type])
91
+    @require_content_types([FILE_TYPE])
92
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
92
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
93
     @hapic.output_file([])
93
     @hapic.output_file([])
94
     def download_file(self, context, request: TracimRequest, hapic_data=None):
94
     def download_file(self, context, request: TracimRequest, hapic_data=None):
115
 
115
 
116
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
116
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
117
     @require_workspace_role(UserRoleInWorkspace.READER)
117
     @require_workspace_role(UserRoleInWorkspace.READER)
118
-    @require_content_types([file_type])
118
+    @require_content_types([FILE_TYPE])
119
     @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
119
     @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
120
     @hapic.output_file([])
120
     @hapic.output_file([])
121
     def download_revisions_file(self, context, request: TracimRequest, hapic_data=None):  # nopep8
121
     def download_revisions_file(self, context, request: TracimRequest, hapic_data=None):  # nopep8
148
     # pdf
148
     # pdf
149
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
149
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
150
     @require_workspace_role(UserRoleInWorkspace.READER)
150
     @require_workspace_role(UserRoleInWorkspace.READER)
151
-    @require_content_types([file_type])
151
+    @require_content_types([FILE_TYPE])
152
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
152
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
153
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
153
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
154
     @hapic.input_query(PageQuerySchema())
154
     @hapic.input_query(PageQuerySchema())
179
 
179
 
180
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
180
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
181
     @require_workspace_role(UserRoleInWorkspace.READER)
181
     @require_workspace_role(UserRoleInWorkspace.READER)
182
-    @require_content_types([file_type])
182
+    @require_content_types([FILE_TYPE])
183
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
183
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
184
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
184
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
185
     @hapic.output_file([])
185
     @hapic.output_file([])
204
 
204
 
205
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
205
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
206
     @require_workspace_role(UserRoleInWorkspace.READER)
206
     @require_workspace_role(UserRoleInWorkspace.READER)
207
-    @require_content_types([file_type])
207
+    @require_content_types([FILE_TYPE])
208
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
208
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
209
     @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
209
     @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
210
     @hapic.input_query(PageQuerySchema())
210
     @hapic.input_query(PageQuerySchema())
239
     # jpg
239
     # jpg
240
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
240
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
241
     @require_workspace_role(UserRoleInWorkspace.READER)
241
     @require_workspace_role(UserRoleInWorkspace.READER)
242
-    @require_content_types([file_type])
242
+    @require_content_types([FILE_TYPE])
243
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
243
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
244
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
244
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
245
     @hapic.input_query(PageQuerySchema())
245
     @hapic.input_query(PageQuerySchema())
272
 
272
 
273
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
273
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
274
     @require_workspace_role(UserRoleInWorkspace.READER)
274
     @require_workspace_role(UserRoleInWorkspace.READER)
275
-    @require_content_types([file_type])
275
+    @require_content_types([FILE_TYPE])
276
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
276
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
277
     @hapic.handle_exception(PreviewDimNotAllowed, HTTPStatus.BAD_REQUEST)
277
     @hapic.handle_exception(PreviewDimNotAllowed, HTTPStatus.BAD_REQUEST)
278
     @hapic.input_query(PageQuerySchema())
278
     @hapic.input_query(PageQuerySchema())
305
 
305
 
306
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
306
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
307
     @require_workspace_role(UserRoleInWorkspace.READER)
307
     @require_workspace_role(UserRoleInWorkspace.READER)
308
-    @require_content_types([file_type])
308
+    @require_content_types([FILE_TYPE])
309
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
309
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
310
     @hapic.handle_exception(PreviewDimNotAllowed, HTTPStatus.BAD_REQUEST)
310
     @hapic.handle_exception(PreviewDimNotAllowed, HTTPStatus.BAD_REQUEST)
311
     @hapic.input_path(RevisionPreviewSizedPathSchema())
311
     @hapic.input_path(RevisionPreviewSizedPathSchema())
342
 
342
 
343
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
343
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
344
     @require_workspace_role(UserRoleInWorkspace.READER)
344
     @require_workspace_role(UserRoleInWorkspace.READER)
345
-    @require_content_types([file_type])
345
+    @require_content_types([FILE_TYPE])
346
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
346
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
347
     @hapic.output_body(AllowedJpgPreviewDimSchema())
347
     @hapic.output_body(AllowedJpgPreviewDimSchema())
348
     def allowed_dim_preview_jpg(self, context, request: TracimRequest, hapic_data=None):  # nopep8
348
     def allowed_dim_preview_jpg(self, context, request: TracimRequest, hapic_data=None):  # nopep8
363
     # File infos
363
     # File infos
364
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
364
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
365
     @require_workspace_role(UserRoleInWorkspace.READER)
365
     @require_workspace_role(UserRoleInWorkspace.READER)
366
-    @require_content_types([file_type])
366
+    @require_content_types([FILE_TYPE])
367
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
367
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
368
     @hapic.output_body(FileContentSchema())
368
     @hapic.output_body(FileContentSchema())
369
     def get_file_infos(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
369
     def get_file_infos(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
387
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
387
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
388
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
388
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
389
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
389
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
390
-    @require_content_types([file_type])
390
+    @require_content_types([FILE_TYPE])
391
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
391
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
392
     @hapic.input_body(FileContentModifySchema())
392
     @hapic.input_body(FileContentModifySchema())
393
     @hapic.output_body(FileContentSchema())
393
     @hapic.output_body(FileContentSchema())
423
 
423
 
424
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
424
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
425
     @require_workspace_role(UserRoleInWorkspace.READER)
425
     @require_workspace_role(UserRoleInWorkspace.READER)
426
-    @require_content_types([file_type])
426
+    @require_content_types([FILE_TYPE])
427
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
427
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
428
     @hapic.output_body(FileRevisionSchema(many=True))
428
     @hapic.output_body(FileRevisionSchema(many=True))
429
     def get_file_revisions(
429
     def get_file_revisions(
456
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
456
     @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
457
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
457
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
458
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
458
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
459
-    @require_content_types([file_type])
459
+    @require_content_types([FILE_TYPE])
460
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
460
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
461
     @hapic.input_body(SetContentStatusSchema())
461
     @hapic.input_body(SetContentStatusSchema())
462
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
462
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8

+ 5 - 5
backend/tracim_backend/views/contents_api/folder_controller.py View File

26
 from tracim_backend.models.context_models import ContentInContext
26
 from tracim_backend.models.context_models import ContentInContext
27
 from tracim_backend.models.context_models import RevisionInContext
27
 from tracim_backend.models.context_models import RevisionInContext
28
 from tracim_backend.app_models.contents import CONTENT_TYPES
28
 from tracim_backend.app_models.contents import CONTENT_TYPES
29
-from tracim_backend.app_models.contents import folder_type
29
+from tracim_backend.app_models.contents import FOLDER_TYPE
30
 from tracim_backend.models.revision_protection import new_revision
30
 from tracim_backend.models.revision_protection import new_revision
31
 
31
 
32
 SWAGGER_TAG__Folders_ENDPOINTS = 'Folders'
32
 SWAGGER_TAG__Folders_ENDPOINTS = 'Folders'
36
 
36
 
37
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
37
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
38
     @require_workspace_role(UserRoleInWorkspace.READER)
38
     @require_workspace_role(UserRoleInWorkspace.READER)
39
-    @require_content_types([folder_type])
39
+    @require_content_types([FOLDER_TYPE])
40
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
40
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
41
     @hapic.output_body(TextBasedContentSchema())
41
     @hapic.output_body(TextBasedContentSchema())
42
     def get_folder(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
42
     def get_folder(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
60
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
60
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
61
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
61
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
62
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
62
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
63
-    @require_content_types([folder_type])
63
+    @require_content_types([FOLDER_TYPE])
64
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
64
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
65
     @hapic.input_body(FolderContentModifySchema())
65
     @hapic.input_body(FolderContentModifySchema())
66
     @hapic.output_body(TextBasedContentSchema())
66
     @hapic.output_body(TextBasedContentSchema())
100
 
100
 
101
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
101
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
102
     @require_workspace_role(UserRoleInWorkspace.READER)
102
     @require_workspace_role(UserRoleInWorkspace.READER)
103
-    @require_content_types([folder_type])
103
+    @require_content_types([FOLDER_TYPE])
104
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
104
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
105
     @hapic.output_body(TextBasedRevisionSchema(many=True))
105
     @hapic.output_body(TextBasedRevisionSchema(many=True))
106
     def get_folder_revisions(
106
     def get_folder_revisions(
132
 
132
 
133
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
133
     @hapic.with_api_doc(tags=[SWAGGER_TAG__Folders_ENDPOINTS])
134
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
134
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
135
-    @require_content_types([folder_type])
135
+    @require_content_types([FOLDER_TYPE])
136
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
136
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
137
     @hapic.input_body(SetContentStatusSchema())
137
     @hapic.input_body(SetContentStatusSchema())
138
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
138
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8

+ 5 - 5
backend/tracim_backend/views/contents_api/html_document_controller.py View File

27
 from tracim_backend.models.context_models import ContentInContext
27
 from tracim_backend.models.context_models import ContentInContext
28
 from tracim_backend.models.context_models import RevisionInContext
28
 from tracim_backend.models.context_models import RevisionInContext
29
 from tracim_backend.app_models.contents import CONTENT_TYPES
29
 from tracim_backend.app_models.contents import CONTENT_TYPES
30
-from tracim_backend.app_models.contents import html_documents_type
30
+from tracim_backend.app_models.contents import HTML_DOCUMENTS_TYPE
31
 from tracim_backend.models.revision_protection import new_revision
31
 from tracim_backend.models.revision_protection import new_revision
32
 
32
 
33
 SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS = 'HTML documents'
33
 SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS = 'HTML documents'
37
 
37
 
38
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
38
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
39
     @require_workspace_role(UserRoleInWorkspace.READER)
39
     @require_workspace_role(UserRoleInWorkspace.READER)
40
-    @require_content_types([html_documents_type])
40
+    @require_content_types([HTML_DOCUMENTS_TYPE])
41
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
41
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
42
     @hapic.output_body(TextBasedContentSchema())
42
     @hapic.output_body(TextBasedContentSchema())
43
     def get_html_document(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
43
     def get_html_document(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
61
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
61
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
62
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
62
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
63
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
63
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
64
-    @require_content_types([html_documents_type])
64
+    @require_content_types([HTML_DOCUMENTS_TYPE])
65
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
65
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
66
     @hapic.input_body(TextBasedContentModifySchema())
66
     @hapic.input_body(TextBasedContentModifySchema())
67
     @hapic.output_body(TextBasedContentSchema())
67
     @hapic.output_body(TextBasedContentSchema())
97
 
97
 
98
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
98
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
99
     @require_workspace_role(UserRoleInWorkspace.READER)
99
     @require_workspace_role(UserRoleInWorkspace.READER)
100
-    @require_content_types([html_documents_type])
100
+    @require_content_types([HTML_DOCUMENTS_TYPE])
101
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
101
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
102
     @hapic.output_body(TextBasedRevisionSchema(many=True))
102
     @hapic.output_body(TextBasedRevisionSchema(many=True))
103
     def get_html_document_revisions(
103
     def get_html_document_revisions(
129
 
129
 
130
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
130
     @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
131
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
131
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
132
-    @require_content_types([html_documents_type])
132
+    @require_content_types([HTML_DOCUMENTS_TYPE])
133
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
133
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
134
     @hapic.input_body(SetContentStatusSchema())
134
     @hapic.input_body(SetContentStatusSchema())
135
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
135
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8

+ 5 - 5
backend/tracim_backend/views/contents_api/threads_controller.py View File

26
 from tracim_backend.models.context_models import ContentInContext
26
 from tracim_backend.models.context_models import ContentInContext
27
 from tracim_backend.models.context_models import RevisionInContext
27
 from tracim_backend.models.context_models import RevisionInContext
28
 from tracim_backend.app_models.contents import CONTENT_TYPES
28
 from tracim_backend.app_models.contents import CONTENT_TYPES
29
-from tracim_backend.app_models.contents import thread_type
29
+from tracim_backend.app_models.contents import THREAD_TYPE
30
 from tracim_backend.models.revision_protection import new_revision
30
 from tracim_backend.models.revision_protection import new_revision
31
 
31
 
32
 SWAGGER_TAG__THREAD_ENDPOINTS = 'Threads'
32
 SWAGGER_TAG__THREAD_ENDPOINTS = 'Threads'
36
 
36
 
37
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
37
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
38
     @require_workspace_role(UserRoleInWorkspace.READER)
38
     @require_workspace_role(UserRoleInWorkspace.READER)
39
-    @require_content_types([thread_type])
39
+    @require_content_types([THREAD_TYPE])
40
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
40
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
41
     @hapic.output_body(TextBasedContentSchema())
41
     @hapic.output_body(TextBasedContentSchema())
42
     def get_thread(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
42
     def get_thread(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
60
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
60
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
61
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
61
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
62
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
62
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
63
-    @require_content_types([thread_type])
63
+    @require_content_types([THREAD_TYPE])
64
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
64
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
65
     @hapic.input_body(TextBasedContentModifySchema())
65
     @hapic.input_body(TextBasedContentModifySchema())
66
     @hapic.output_body(TextBasedContentSchema())
66
     @hapic.output_body(TextBasedContentSchema())
96
 
96
 
97
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
97
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
98
     @require_workspace_role(UserRoleInWorkspace.READER)
98
     @require_workspace_role(UserRoleInWorkspace.READER)
99
-    @require_content_types([thread_type])
99
+    @require_content_types([THREAD_TYPE])
100
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
100
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
101
     @hapic.output_body(TextBasedRevisionSchema(many=True))
101
     @hapic.output_body(TextBasedRevisionSchema(many=True))
102
     def get_thread_revisions(
102
     def get_thread_revisions(
128
 
128
 
129
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
129
     @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
130
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
130
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
131
-    @require_content_types([thread_type])
131
+    @require_content_types([THREAD_TYPE])
132
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
132
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
133
     @hapic.input_body(SetContentStatusSchema())
133
     @hapic.input_body(SetContentStatusSchema())
134
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
134
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8

+ 7 - 7
backend/tracim_backend/views/core_api/schemas.py View File

42
 from tracim_backend.models.context_models import LoginCredentials
42
 from tracim_backend.models.context_models import LoginCredentials
43
 from tracim_backend.models.data import UserRoleInWorkspace
43
 from tracim_backend.models.data import UserRoleInWorkspace
44
 from tracim_backend.models.data import ActionDescription
44
 from tracim_backend.models.data import ActionDescription
45
-from tracim_backend.app_models.validator import ALL_CONTENT_TYPES_VALIDATOR
45
+from tracim_backend.app_models.validator import all_content_types_validator
46
 
46
 
47
 
47
 
48
 class UserDigestSchema(marshmallow.Schema):
48
 class UserDigestSchema(marshmallow.Schema):
392
     content_type = marshmallow.fields.String(
392
     content_type = marshmallow.fields.String(
393
         example=CONTENT_TYPES.Any_SLUG,
393
         example=CONTENT_TYPES.Any_SLUG,
394
         default=CONTENT_TYPES.Any_SLUG,
394
         default=CONTENT_TYPES.Any_SLUG,
395
-        validate=ALL_CONTENT_TYPES_VALIDATOR
395
+        validate=all_content_types_validator
396
     )
396
     )
397
 
397
 
398
     @post_load
398
     @post_load
643
 class ContentTypeSchema(marshmallow.Schema):
643
 class ContentTypeSchema(marshmallow.Schema):
644
     slug = marshmallow.fields.String(
644
     slug = marshmallow.fields.String(
645
         example='pagehtml',
645
         example='pagehtml',
646
-        validate=ALL_CONTENT_TYPES_VALIDATOR,
646
+        validate=all_content_types_validator,
647
     )
647
     )
648
     fa_icon = marshmallow.fields.String(
648
     fa_icon = marshmallow.fields.String(
649
         example='fa-file-text-o',
649
         example='fa-file-text-o',
697
     )
697
     )
698
     content_type = marshmallow.fields.String(
698
     content_type = marshmallow.fields.String(
699
         example='html-document',
699
         example='html-document',
700
-        validate=ALL_CONTENT_TYPES_VALIDATOR,
700
+        validate=all_content_types_validator,
701
     )
701
     )
702
     parent_id = marshmallow.fields.Integer(
702
     parent_id = marshmallow.fields.Integer(
703
         example=35,
703
         example=35,
732
     label = marshmallow.fields.Str(example='Intervention Report 12')
732
     label = marshmallow.fields.Str(example='Intervention Report 12')
733
     content_type = marshmallow.fields.Str(
733
     content_type = marshmallow.fields.Str(
734
         example='html-document',
734
         example='html-document',
735
-        validate=ALL_CONTENT_TYPES_VALIDATOR,
735
+        validate=all_content_types_validator,
736
     )
736
     )
737
     sub_content_types = marshmallow.fields.List(
737
     sub_content_types = marshmallow.fields.List(
738
         marshmallow.fields.String(
738
         marshmallow.fields.String(
739
             example='html-content',
739
             example='html-content',
740
-            validate=ALL_CONTENT_TYPES_VALIDATOR
740
+            validate=all_content_types_validator
741
         ),
741
         ),
742
         description='list of content types allowed as sub contents. '
742
         description='list of content types allowed as sub contents. '
743
                     'This field is required for folder contents, '
743
                     'This field is required for folder contents, '
887
     sub_content_types = marshmallow.fields.List(
887
     sub_content_types = marshmallow.fields.List(
888
         marshmallow.fields.String(
888
         marshmallow.fields.String(
889
             example='html-document',
889
             example='html-document',
890
-            validate=ALL_CONTENT_TYPES_VALIDATOR,
890
+            validate=all_content_types_validator,
891
         ),
891
         ),
892
         description='list of content types allowed as sub contents. '
892
         description='list of content types allowed as sub contents. '
893
                     'This field is required for folder contents, '
893
                     'This field is required for folder contents, '

+ 2 - 2
backend/tracim_backend/views/core_api/system_controller.py View File

13
     from http import client as HTTPStatus
13
     from http import client as HTTPStatus
14
 
14
 
15
 from tracim_backend.lib.utils.request import TracimRequest
15
 from tracim_backend.lib.utils.request import TracimRequest
16
-from tracim_backend.extensions import hapic, APP_LIST
16
+from tracim_backend.extensions import hapic, app_list
17
 from tracim_backend.views.controllers import Controller
17
 from tracim_backend.views.controllers import Controller
18
 from tracim_backend.views.core_api.schemas import ApplicationSchema
18
 from tracim_backend.views.core_api.schemas import ApplicationSchema
19
 from tracim_backend.views.core_api.schemas import ContentTypeSchema
19
 from tracim_backend.views.core_api.schemas import ContentTypeSchema
32
         """
32
         """
33
         app_config = request.registry.settings['CFG']
33
         app_config = request.registry.settings['CFG']
34
         app_api = ApplicationApi(
34
         app_api = ApplicationApi(
35
-            app_list=APP_LIST,
35
+            app_list=app_list,
36
         )
36
         )
37
         return app_api.get_all()
37
         return app_api.get_all()
38
 
38
 

+ 2 - 2
backend/tracim_backend/views/frontend.py View File

2
 
2
 
3
 from pyramid.renderers import render_to_response
3
 from pyramid.renderers import render_to_response
4
 from pyramid.config import Configurator
4
 from pyramid.config import Configurator
5
-from tracim_backend.extensions import APP_LIST
5
+from tracim_backend.extensions import app_list
6
 from tracim_backend.exceptions import PageNotFound
6
 from tracim_backend.exceptions import PageNotFound
7
 from tracim_backend.lib.core.application import ApplicationApi
7
 from tracim_backend.lib.core.application import ApplicationApi
8
 from tracim_backend.lib.utils.utils import Color
8
 from tracim_backend.lib.utils.utils import Color
36
         # TODO - G.M - 2018-08-07 - Refactor autogen valid app list for frontend
36
         # TODO - G.M - 2018-08-07 - Refactor autogen valid app list for frontend
37
         frontend_apps = []
37
         frontend_apps = []
38
         app_api = ApplicationApi(
38
         app_api = ApplicationApi(
39
-            app_list=APP_LIST,
39
+            app_list=app_list,
40
         )
40
         )
41
         applications = app_api.get_all()
41
         applications = app_api.get_all()
42
         for app in applications:
42
         for app in applications: