Browse Source

fix import + small refactor

Guénaël Muller 5 years ago
parent
commit
e7a3fe077a

+ 3 - 0
backend/tracim_backend/app_models/applications.py View File

@@ -2,6 +2,9 @@
2 2
 import typing
3 3
 
4 4
 from tracim_backend.app_models.contents import ContentType
5
+if typing.TYPE_CHECKING:
6
+    from tracim_backend.config import CFG
7
+    from tracim_backend.app_models.contents import ContentStatus
5 8
 
6 9
 
7 10
 class Application(object):

+ 6 - 5
backend/tracim_backend/app_models/contents.py View File

@@ -9,6 +9,8 @@ from tracim_backend.exceptions import ContentStatusNotExist
9 9
 ####
10 10
 # Content Status
11 11
 from tracim_backend.lib.core.application import ApplicationApi
12
+if typing.TYPE_CHECKING:
13
+    from tracim_backend.app_models.applications import Application
12 14
 
13 15
 
14 16
 class GlobalStatus(Enum):
@@ -167,19 +169,19 @@ class ContentTypeList(object):
167 169
 
168 170
     @property
169 171
     def Folder(self):
170
-        return self.get_one_by_slug('folder')
172
+        return self.get_one_by_slug(folder_type)
171 173
 
172 174
     @property
173 175
     def File(self):
174
-        return self.get_one_by_slug('file')
176
+        return self.get_one_by_slug(file_type)
175 177
 
176 178
     @property
177 179
     def Page(self):
178
-        return self.get_one_by_slug('html-document')
180
+        return self.get_one_by_slug(html_documents_type)
179 181
 
180 182
     @property
181 183
     def Thread(self):
182
-        return self.get_one_by_slug('thread')
184
+        return self.get_one_by_slug(thread_type)
183 185
 
184 186
     def __init__(self, app_list: typing.List['Application']):
185 187
         self.app_list = app_list
@@ -190,7 +192,6 @@ class ContentTypeList(object):
190 192
     def _content_types(self):
191 193
         app_api = ApplicationApi(self.app_list)
192 194
         content_types = app_api.get_content_types()
193
-        # content_types.extend(self._special_contents_types)
194 195
         return content_types
195 196
 
196 197
     def get_one_by_slug(self, slug: str) -> ContentType:

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

@@ -7,7 +7,9 @@ import colorsys
7 7
 
8 8
 from redis import Redis
9 9
 from rq import Queue
10
-
10
+import typing
11
+if typing.TYPE_CHECKING:
12
+    from tracim_backend.config import CFG
11 13
 
12 14
 DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
13 15
 DEFAULT_WEBDAV_CONFIG_FILE = "wsgidav.conf"
@@ -138,6 +140,7 @@ def clamp(val: float, minimum: float = 0.0, maximum: float= 255.0) -> int:
138 140
 COLOR_DARKEN_SCALE_FACTOR = 0.85
139 141
 COLOR_LIGHTEN_SCALE_FACTOR = 1.15
140 142
 
143
+
141 144
 class Color(object):
142 145
     def __init__(self, base_hex_code: str):
143 146
         """