Guénaël Muller hace 6 años
padre
commit
a0ab44e6bc
Se han modificado 1 ficheros con 18 adiciones y 1 borrados
  1. 18 1
      backend/tracim_backend/models/contents.py

+ 18 - 1
backend/tracim_backend/models/contents.py Ver fichero

@@ -86,9 +86,11 @@ class ContentStatusList(object):
86 86
         raise ContentStatusNotExist()
87 87
 
88 88
     def allowed_slugs_values(self) -> typing.List[str]:
89
+        """ Get alls slugs"""
89 90
         return [item.slug for item in self._content_status]
90 91
 
91 92
     def allowed(self) -> typing.List[ContentStatus]:
93
+        """ Get all status"""
92 94
         return [item for item in self._content_status]
93 95
 
94 96
     def get_default_status(self) -> ContentStatus:
@@ -216,7 +218,11 @@ class ContentTypeList(object):
216 218
         self._special_contents_types = [self.Comment]
217 219
         self._extra_slugs = [self.Any_SLUG]
218 220
 
219
-    def get_one_by_slug(self, slug: str):
221
+    def get_one_by_slug(self, slug: str) -> ContentType:
222
+        """
223
+        Get ContentType object according to slug
224
+        match for both slug and slug_alias
225
+        """
220 226
         content_types = self._content_types.copy()
221 227
         content_types.extend(self._special_contents_types)
222 228
         for item in content_types:
@@ -225,10 +231,21 @@ class ContentTypeList(object):
225 231
         raise ContentTypeNotExist()
226 232
 
227 233
     def endpoint_allowed_types_slug(self) -> typing.List[str]:
234
+        """
235
+        Return restricted list of content_type:
236
+        dont return special content_type like  comment, don't return
237
+        "any" slug, dont return content type slug alias , don't return event.
238
+        Useful to restrict slug param in schema.
239
+        """
228 240
         allowed_type_slug = [contents_type.slug for contents_type in self._content_types]  # nopep8
229 241
         return allowed_type_slug
230 242
 
231 243
     def query_allowed_types_slugs(self) -> typing.List[str]:
244
+        """
245
+        Return alls allowed types slug : content_type slug + all alias, any
246
+        and special content_type like comment. Do not return event.
247
+        Usefull allowed value to perform query to database.
248
+        """
232 249
         allowed_types_slug = []
233 250
         for content_type in self._content_types:
234 251
             allowed_types_slug.append(content_type.slug)