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

+ 19 - 5
tracim/views/contents_api/html_document_controller.py View File

1
 # coding=utf-8
1
 # coding=utf-8
2
+import typing
3
+
2
 import transaction
4
 import transaction
3
 from pyramid.config import Configurator
5
 from pyramid.config import Configurator
4
 
6
 
25
 from tracim.exceptions import InsufficientUserWorkspaceRole
27
 from tracim.exceptions import InsufficientUserWorkspaceRole
26
 from tracim.exceptions import NotAuthenticated
28
 from tracim.exceptions import NotAuthenticated
27
 from tracim.exceptions import AuthenticationFailed
29
 from tracim.exceptions import AuthenticationFailed
30
+from tracim.models.context_models import ContentInContext
31
+from tracim.models.context_models import RevisionInContext
28
 from tracim.models.contents import ContentTypeLegacy as ContentType
32
 from tracim.models.contents import ContentTypeLegacy as ContentType
29
 from tracim.models.contents import html_documents_type
33
 from tracim.models.contents import html_documents_type
30
 from tracim.models.revision_protection import new_revision
34
 from tracim.models.revision_protection import new_revision
44
     @require_content_types([html_documents_type])
48
     @require_content_types([html_documents_type])
45
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
49
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
46
     @hapic.output_body(HtmlDocumentContentSchema())
50
     @hapic.output_body(HtmlDocumentContentSchema())
47
-    def get_html_document(self, context, request: TracimRequest, hapic_data=None):  # nopep8
51
+    def get_html_document(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
48
         """
52
         """
49
         Get html document content
53
         Get html document content
50
         """
54
         """
70
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
74
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
71
     @hapic.input_body(HtmlDocumentModifySchema())
75
     @hapic.input_body(HtmlDocumentModifySchema())
72
     @hapic.output_body(HtmlDocumentContentSchema())
76
     @hapic.output_body(HtmlDocumentContentSchema())
73
-    def update_html_document(self, context, request: TracimRequest, hapic_data=None):  # nopep8
77
+    def update_html_document(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
74
         """
78
         """
75
         update_html_document
79
         update_html_document
76
         """
80
         """
107
     @require_content_types([html_documents_type])
111
     @require_content_types([html_documents_type])
108
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
112
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
109
     @hapic.output_body(HtmlDocumentRevisionSchema(many=True))
113
     @hapic.output_body(HtmlDocumentRevisionSchema(many=True))
110
-    def get_html_document_revisions(self, context, request: TracimRequest, hapic_data=None):  # nopep8
114
+    def get_html_document_revisions(
115
+            self,
116
+            context,
117
+            request: TracimRequest,
118
+            hapic_data=None
119
+    ) -> typing.List[RevisionInContext]:
111
         """
120
         """
112
         get html_document revisions
121
         get html_document revisions
113
         """
122
         """
137
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
146
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
138
     @hapic.input_body(SetContentStatusSchema())
147
     @hapic.input_body(SetContentStatusSchema())
139
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
148
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
140
-    def set_html_document_status(self, context, request: TracimRequest, hapic_data=None):  # nopep8
149
+    def set_html_document_status(
150
+            self,
151
+            context,
152
+            request: TracimRequest,
153
+            hapic_data=None
154
+    ) -> None:
141
         """
155
         """
142
         set html_document status
156
         set html_document status
143
         """
157
         """
163
             api.save(content)
177
             api.save(content)
164
         return
178
         return
165
 
179
 
166
-    def bind(self, configurator: Configurator):
180
+    def bind(self, configurator: Configurator) -> None:
167
         # Get html-document
181
         # Get html-document
168
         configurator.add_route(
182
         configurator.add_route(
169
             'html_document',
183
             'html_document',

+ 13 - 6
tracim/views/contents_api/threads_controller.py View File

1
 # coding=utf-8
1
 # coding=utf-8
2
+import typing
3
+
2
 import transaction
4
 import transaction
3
 from pyramid.config import Configurator
5
 from pyramid.config import Configurator
4
-
5
 from tracim.models.data import UserRoleInWorkspace
6
 from tracim.models.data import UserRoleInWorkspace
6
 
7
 
7
 try:  # Python 3.5+
8
 try:  # Python 3.5+
25
 from tracim.exceptions import InsufficientUserWorkspaceRole
26
 from tracim.exceptions import InsufficientUserWorkspaceRole
26
 from tracim.exceptions import NotAuthenticated
27
 from tracim.exceptions import NotAuthenticated
27
 from tracim.exceptions import AuthenticationFailed
28
 from tracim.exceptions import AuthenticationFailed
29
+from tracim.models.context_models import ContentInContext, RevisionInContext
28
 from tracim.models.contents import ContentTypeLegacy as ContentType
30
 from tracim.models.contents import ContentTypeLegacy as ContentType
29
 from tracim.models.contents import thread_type
31
 from tracim.models.contents import thread_type
30
 from tracim.models.revision_protection import new_revision
32
 from tracim.models.revision_protection import new_revision
44
     @require_content_types([thread_type])
46
     @require_content_types([thread_type])
45
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
47
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
46
     @hapic.output_body(ThreadContentSchema())
48
     @hapic.output_body(ThreadContentSchema())
47
-    def get_thread(self, context, request: TracimRequest, hapic_data=None):  # nopep8
49
+    def get_thread(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
48
         """
50
         """
49
         Get thread content
51
         Get thread content
50
         """
52
         """
70
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
72
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
71
     @hapic.input_body(ThreadModifySchema())
73
     @hapic.input_body(ThreadModifySchema())
72
     @hapic.output_body(ThreadContentSchema())
74
     @hapic.output_body(ThreadContentSchema())
73
-    def update_thread(self, context, request: TracimRequest, hapic_data=None):
75
+    def update_thread(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext:  # nopep8
74
         """
76
         """
75
         update thread
77
         update thread
76
         """
78
         """
107
     @require_content_types([thread_type])
109
     @require_content_types([thread_type])
108
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
110
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
109
     @hapic.output_body(ThreadRevisionSchema(many=True))
111
     @hapic.output_body(ThreadRevisionSchema(many=True))
110
-    def get_thread_revisions(self, context, request: TracimRequest, hapic_data=None):  # nopep8
112
+    def get_thread_revisions(
113
+            self,
114
+            context,
115
+            request: TracimRequest,
116
+            hapic_data=None
117
+    ) -> typing.List[RevisionInContext]:
111
         """
118
         """
112
         get thread revisions
119
         get thread revisions
113
         """
120
         """
137
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
144
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
138
     @hapic.input_body(SetContentStatusSchema())
145
     @hapic.input_body(SetContentStatusSchema())
139
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
146
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
140
-    def set_thread_status(self, context, request: TracimRequest, hapic_data=None):  # nopep8
147
+    def set_thread_status(self, context, request: TracimRequest, hapic_data=None) -> None:  # nopep8
141
         """
148
         """
142
         set thread status
149
         set thread status
143
         """
150
         """
163
             api.save(content)
170
             api.save(content)
164
         return
171
         return
165
 
172
 
166
-    def bind(self, configurator: Configurator):
173
+    def bind(self, configurator: Configurator) -> None:
167
         # Get thread
174
         # Get thread
168
         configurator.add_route(
175
         configurator.add_route(
169
             'thread',
176
             'thread',