Browse Source

get_all instead of allowed method naming for contentstatuslist

Guénaël Muller 6 years ago
parent
commit
1b06dd2314

+ 1 - 1
backend/tracim_backend/lib/core/content.py View File

1092
         folder.properties = properties
1092
         folder.properties = properties
1093
 
1093
 
1094
     def set_status(self, content: Content, new_status: str):
1094
     def set_status(self, content: Content, new_status: str):
1095
-        if new_status in CONTENT_STATUS.allowed_slugs_values():
1095
+        if new_status in CONTENT_STATUS.get_all_slugs_values():
1096
             content.status = new_status
1096
             content.status = new_status
1097
             content.revision_type = ActionDescription.STATUS_UPDATE
1097
             content.revision_type = ActionDescription.STATUS_UPDATE
1098
         else:
1098
         else:

+ 9 - 9
backend/tracim_backend/models/contents.py View File

85
                 return item
85
                 return item
86
         raise ContentStatusNotExist()
86
         raise ContentStatusNotExist()
87
 
87
 
88
-    def allowed_slugs_values(self) -> typing.List[str]:
88
+    def get_all_slugs_values(self) -> typing.List[str]:
89
         """ Get alls slugs"""
89
         """ Get alls slugs"""
90
         return [item.slug for item in self._content_status]
90
         return [item.slug for item in self._content_status]
91
 
91
 
92
-    def allowed(self) -> typing.List[ContentStatus]:
92
+    def get_all(self) -> typing.List[ContentStatus]:
93
         """ Get all status"""
93
         """ Get all status"""
94
         return [item for item in self._content_status]
94
         return [item for item in self._content_status]
95
 
95
 
137
     hexcolor=thread.hexcolor,
137
     hexcolor=thread.hexcolor,
138
     label='Thread',
138
     label='Thread',
139
     creation_label='Discuss about a topic',
139
     creation_label='Discuss about a topic',
140
-    available_statuses=CONTENT_STATUS.allowed(),
140
+    available_statuses=CONTENT_STATUS.get_all(),
141
 )
141
 )
142
 
142
 
143
 file_type = ContentType(
143
 file_type = ContentType(
146
     hexcolor=_file.hexcolor,
146
     hexcolor=_file.hexcolor,
147
     label='File',
147
     label='File',
148
     creation_label='Upload a file',
148
     creation_label='Upload a file',
149
-    available_statuses=CONTENT_STATUS.allowed(),
149
+    available_statuses=CONTENT_STATUS.get_all(),
150
 )
150
 )
151
 
151
 
152
 markdownpluspage_type = ContentType(
152
 markdownpluspage_type = ContentType(
155
     hexcolor=markdownpluspage.hexcolor,
155
     hexcolor=markdownpluspage.hexcolor,
156
     label='Rich Markdown File',
156
     label='Rich Markdown File',
157
     creation_label='Create a Markdown document',
157
     creation_label='Create a Markdown document',
158
-    available_statuses=CONTENT_STATUS.allowed(),
158
+    available_statuses=CONTENT_STATUS.get_all(),
159
 )
159
 )
160
 
160
 
161
 html_documents_type = ContentType(
161
 html_documents_type = ContentType(
164
     hexcolor=html_documents.hexcolor,
164
     hexcolor=html_documents.hexcolor,
165
     label='Text Document',
165
     label='Text Document',
166
     creation_label='Write a document',
166
     creation_label='Write a document',
167
-    available_statuses=CONTENT_STATUS.allowed(),
167
+    available_statuses=CONTENT_STATUS.get_all(),
168
     slug_alias=['page']
168
     slug_alias=['page']
169
 )
169
 )
170
 
170
 
175
     hexcolor=thread.hexcolor,
175
     hexcolor=thread.hexcolor,
176
     label='Folder',
176
     label='Folder',
177
     creation_label='Create collection of any documents',
177
     creation_label='Create collection of any documents',
178
-    available_statuses=CONTENT_STATUS.allowed(),
178
+    available_statuses=CONTENT_STATUS.get_all(),
179
 )
179
 )
180
 
180
 
181
 
181
 
186
     hexcolor=thread.hexcolor,
186
     hexcolor=thread.hexcolor,
187
     label='Event',
187
     label='Event',
188
     creation_label='Event',
188
     creation_label='Event',
189
-    available_statuses=CONTENT_STATUS.allowed(),
189
+    available_statuses=CONTENT_STATUS.get_all(),
190
 )
190
 )
191
 
191
 
192
 # TODO - G.M - 31-05-2018 - Set Better Event params
192
 # TODO - G.M - 31-05-2018 - Set Better Event params
196
     hexcolor=thread.hexcolor,
196
     hexcolor=thread.hexcolor,
197
     label='Comment',
197
     label='Comment',
198
     creation_label='Comment',
198
     creation_label='Comment',
199
-    available_statuses=CONTENT_STATUS.allowed(),
199
+    available_statuses=CONTENT_STATUS.get_all(),
200
 )
200
 )
201
 
201
 
202
 
202
 

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

696
     )
696
     )
697
     status = marshmallow.fields.Str(
697
     status = marshmallow.fields.Str(
698
         example='closed-deprecated',
698
         example='closed-deprecated',
699
-        validate=OneOf(CONTENT_STATUS.allowed_slugs_values()),
699
+        validate=OneOf(CONTENT_STATUS.get_all_slugs_values()),
700
         description='this slug is found in content_type available statuses',
700
         description='this slug is found in content_type available statuses',
701
         default=open_status
701
         default=open_status
702
     )
702
     )
841
 class SetContentStatusSchema(marshmallow.Schema):
841
 class SetContentStatusSchema(marshmallow.Schema):
842
     status = marshmallow.fields.Str(
842
     status = marshmallow.fields.Str(
843
         example='closed-deprecated',
843
         example='closed-deprecated',
844
-        validate=OneOf(CONTENT_STATUS.allowed_slugs_values()),
844
+        validate=OneOf(CONTENT_STATUS.get_all_slugs_values()),
845
         description='this slug is found in content_type available statuses',
845
         description='this slug is found in content_type available statuses',
846
         default=open_status,
846
         default=open_status,
847
         required=True,
847
         required=True,