Selaa lähdekoodia

get_all instead of allowed method naming for contentstatuslist

Guénaël Muller 6 vuotta sitten
vanhempi
commit
1b06dd2314

+ 1 - 1
backend/tracim_backend/lib/core/content.py Näytä tiedosto

@@ -1092,7 +1092,7 @@ class ContentApi(object):
1092 1092
         folder.properties = properties
1093 1093
 
1094 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 1096
             content.status = new_status
1097 1097
             content.revision_type = ActionDescription.STATUS_UPDATE
1098 1098
         else:

+ 9 - 9
backend/tracim_backend/models/contents.py Näytä tiedosto

@@ -85,11 +85,11 @@ class ContentStatusList(object):
85 85
                 return item
86 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 89
         """ Get alls slugs"""
90 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 93
         """ Get all status"""
94 94
         return [item for item in self._content_status]
95 95
 
@@ -137,7 +137,7 @@ thread_type = ContentType(
137 137
     hexcolor=thread.hexcolor,
138 138
     label='Thread',
139 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 143
 file_type = ContentType(
@@ -146,7 +146,7 @@ file_type = ContentType(
146 146
     hexcolor=_file.hexcolor,
147 147
     label='File',
148 148
     creation_label='Upload a file',
149
-    available_statuses=CONTENT_STATUS.allowed(),
149
+    available_statuses=CONTENT_STATUS.get_all(),
150 150
 )
151 151
 
152 152
 markdownpluspage_type = ContentType(
@@ -155,7 +155,7 @@ markdownpluspage_type = ContentType(
155 155
     hexcolor=markdownpluspage.hexcolor,
156 156
     label='Rich Markdown File',
157 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 161
 html_documents_type = ContentType(
@@ -164,7 +164,7 @@ html_documents_type = ContentType(
164 164
     hexcolor=html_documents.hexcolor,
165 165
     label='Text Document',
166 166
     creation_label='Write a document',
167
-    available_statuses=CONTENT_STATUS.allowed(),
167
+    available_statuses=CONTENT_STATUS.get_all(),
168 168
     slug_alias=['page']
169 169
 )
170 170
 
@@ -175,7 +175,7 @@ folder_type = ContentType(
175 175
     hexcolor=thread.hexcolor,
176 176
     label='Folder',
177 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,7 +186,7 @@ event_type = ContentType(
186 186
     hexcolor=thread.hexcolor,
187 187
     label='Event',
188 188
     creation_label='Event',
189
-    available_statuses=CONTENT_STATUS.allowed(),
189
+    available_statuses=CONTENT_STATUS.get_all(),
190 190
 )
191 191
 
192 192
 # TODO - G.M - 31-05-2018 - Set Better Event params
@@ -196,7 +196,7 @@ comment_type = ContentType(
196 196
     hexcolor=thread.hexcolor,
197 197
     label='Comment',
198 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 Näytä tiedosto

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