|
@@ -19,9 +19,9 @@ class GlobalStatus(Enum):
|
19
|
19
|
CLOSED = 'closed'
|
20
|
20
|
|
21
|
21
|
|
22
|
|
-class NewContentStatus(object):
|
|
22
|
+class ContentStatus(object):
|
23
|
23
|
"""
|
24
|
|
- Future ContentStatus object class
|
|
24
|
+ ContentStatus object class
|
25
|
25
|
"""
|
26
|
26
|
def __init__(
|
27
|
27
|
self,
|
|
@@ -38,7 +38,7 @@ class NewContentStatus(object):
|
38
|
38
|
self.hexcolor = hexcolor
|
39
|
39
|
|
40
|
40
|
|
41
|
|
-open_status = NewContentStatus(
|
|
41
|
+open_status = ContentStatus(
|
42
|
42
|
slug='open',
|
43
|
43
|
global_status=GlobalStatus.OPEN.value,
|
44
|
44
|
label='Open',
|
|
@@ -46,7 +46,7 @@ open_status = NewContentStatus(
|
46
|
46
|
hexcolor='#3f52e3',
|
47
|
47
|
)
|
48
|
48
|
|
49
|
|
-closed_validated_status = NewContentStatus(
|
|
49
|
+closed_validated_status = ContentStatus(
|
50
|
50
|
slug='closed-validated',
|
51
|
51
|
global_status=GlobalStatus.CLOSED.value,
|
52
|
52
|
label='Validated',
|
|
@@ -54,7 +54,7 @@ closed_validated_status = NewContentStatus(
|
54
|
54
|
hexcolor='#008000',
|
55
|
55
|
)
|
56
|
56
|
|
57
|
|
-closed_unvalidated_status = NewContentStatus(
|
|
57
|
+closed_unvalidated_status = ContentStatus(
|
58
|
58
|
slug='closed-unvalidated',
|
59
|
59
|
global_status=GlobalStatus.CLOSED.value,
|
60
|
60
|
label='Cancelled',
|
|
@@ -62,7 +62,7 @@ closed_unvalidated_status = NewContentStatus(
|
62
|
62
|
hexcolor='#f63434',
|
63
|
63
|
)
|
64
|
64
|
|
65
|
|
-closed_deprecated_status = NewContentStatus(
|
|
65
|
+closed_deprecated_status = ContentStatus(
|
66
|
66
|
slug='closed-deprecated',
|
67
|
67
|
global_status=GlobalStatus.CLOSED.value,
|
68
|
68
|
label='Deprecated',
|
|
@@ -71,45 +71,37 @@ closed_deprecated_status = NewContentStatus(
|
71
|
71
|
)
|
72
|
72
|
|
73
|
73
|
|
74
|
|
-CONTENT_DEFAULT_STATUS = [
|
75
|
|
- open_status,
|
76
|
|
- closed_validated_status,
|
77
|
|
- closed_unvalidated_status,
|
78
|
|
- closed_deprecated_status,
|
79
|
|
-]
|
|
74
|
+class ContentStatusList(object):
|
80
|
75
|
|
|
76
|
+ OPEN = open_status
|
81
|
77
|
|
82
|
|
-class ContentStatusLegacy(NewContentStatus):
|
83
|
|
- """
|
84
|
|
- Temporary remplacement object for Legacy ContentStatus Object
|
85
|
|
- """
|
86
|
|
- OPEN = open_status.slug
|
87
|
|
- CLOSED_VALIDATED = closed_validated_status.slug
|
88
|
|
- CLOSED_UNVALIDATED = closed_unvalidated_status.slug
|
89
|
|
- CLOSED_DEPRECATED = closed_deprecated_status.slug
|
|
78
|
+ def __init__(self, extend_content_status: typing.List[ContentStatus]):
|
|
79
|
+ self._content_status = [self.OPEN]
|
|
80
|
+ self._content_status.extend(extend_content_status)
|
90
|
81
|
|
91
|
|
- def __init__(self, slug: str):
|
92
|
|
- for status in CONTENT_DEFAULT_STATUS:
|
93
|
|
- if slug == status.slug:
|
94
|
|
- super(ContentStatusLegacy, self).__init__(
|
95
|
|
- slug=status.slug,
|
96
|
|
- global_status=status.global_status,
|
97
|
|
- label=status.label,
|
98
|
|
- fa_icon=status.fa_icon,
|
99
|
|
- hexcolor=status.hexcolor,
|
100
|
|
- )
|
101
|
|
- return
|
|
82
|
+ def get_one_by_slug(self, slug: str) -> ContentStatus:
|
|
83
|
+ for item in self._content_status:
|
|
84
|
+ if item.slug == slug:
|
|
85
|
+ return item
|
102
|
86
|
raise ContentStatusNotExist()
|
103
|
87
|
|
104
|
|
- @classmethod
|
105
|
|
- def all(cls, type='') -> ['NewContentStatus']:
|
106
|
|
- return CONTENT_DEFAULT_STATUS
|
|
88
|
+ def allowed_slugs_values(self) -> typing.List[str]:
|
|
89
|
+ return [item.slug for item in self._content_status]
|
107
|
90
|
|
108
|
|
- @classmethod
|
109
|
|
- def allowed_values(cls):
|
110
|
|
- return [status.slug for status in CONTENT_DEFAULT_STATUS]
|
|
91
|
+ def allowed(self) -> typing.List[ContentStatus]:
|
|
92
|
+ return [item for item in self._content_status]
|
111
|
93
|
|
|
94
|
+ def get_default_status(self) -> ContentStatus:
|
|
95
|
+ return self.OPEN
|
112
|
96
|
|
|
97
|
+
|
|
98
|
+CONTENT_STATUS = ContentStatusList(
|
|
99
|
+ [
|
|
100
|
+ closed_validated_status,
|
|
101
|
+ closed_unvalidated_status,
|
|
102
|
+ closed_deprecated_status,
|
|
103
|
+ ]
|
|
104
|
+)
|
113
|
105
|
####
|
114
|
106
|
# ContentType
|
115
|
107
|
|
|
@@ -125,7 +117,7 @@ class NewContentType(object):
|
125
|
117
|
hexcolor: str,
|
126
|
118
|
label: str,
|
127
|
119
|
creation_label: str,
|
128
|
|
- available_statuses: typing.List[NewContentStatus],
|
|
120
|
+ available_statuses: typing.List[ContentStatus],
|
129
|
121
|
|
130
|
122
|
):
|
131
|
123
|
self.slug = slug
|
|
@@ -142,7 +134,7 @@ thread_type = NewContentType(
|
142
|
134
|
hexcolor=thread.hexcolor,
|
143
|
135
|
label='Thread',
|
144
|
136
|
creation_label='Discuss about a topic',
|
145
|
|
- available_statuses=CONTENT_DEFAULT_STATUS,
|
|
137
|
+ available_statuses=CONTENT_STATUS.allowed(),
|
146
|
138
|
)
|
147
|
139
|
|
148
|
140
|
file_type = NewContentType(
|
|
@@ -151,7 +143,7 @@ file_type = NewContentType(
|
151
|
143
|
hexcolor=_file.hexcolor,
|
152
|
144
|
label='File',
|
153
|
145
|
creation_label='Upload a file',
|
154
|
|
- available_statuses=CONTENT_DEFAULT_STATUS,
|
|
146
|
+ available_statuses=CONTENT_STATUS.allowed(),
|
155
|
147
|
)
|
156
|
148
|
|
157
|
149
|
markdownpluspage_type = NewContentType(
|
|
@@ -160,7 +152,7 @@ markdownpluspage_type = NewContentType(
|
160
|
152
|
hexcolor=markdownpluspage.hexcolor,
|
161
|
153
|
label='Rich Markdown File',
|
162
|
154
|
creation_label='Create a Markdown document',
|
163
|
|
- available_statuses=CONTENT_DEFAULT_STATUS,
|
|
155
|
+ available_statuses=CONTENT_STATUS.allowed(),
|
164
|
156
|
)
|
165
|
157
|
|
166
|
158
|
html_documents_type = NewContentType(
|
|
@@ -169,7 +161,7 @@ html_documents_type = NewContentType(
|
169
|
161
|
hexcolor=html_documents.hexcolor,
|
170
|
162
|
label='Text Document',
|
171
|
163
|
creation_label='Write a document',
|
172
|
|
- available_statuses=CONTENT_DEFAULT_STATUS,
|
|
164
|
+ available_statuses=CONTENT_STATUS.allowed(),
|
173
|
165
|
)
|
174
|
166
|
|
175
|
167
|
# TODO - G.M - 31-05-2018 - Set Better folder params
|
|
@@ -179,7 +171,7 @@ folder_type = NewContentType(
|
179
|
171
|
hexcolor=thread.hexcolor,
|
180
|
172
|
label='Folder',
|
181
|
173
|
creation_label='Create collection of any documents',
|
182
|
|
- available_statuses=CONTENT_DEFAULT_STATUS,
|
|
174
|
+ available_statuses=CONTENT_STATUS.allowed(),
|
183
|
175
|
)
|
184
|
176
|
|
185
|
177
|
CONTENT_DEFAULT_TYPE = [
|
|
@@ -197,7 +189,7 @@ event_type = NewContentType(
|
197
|
189
|
hexcolor=thread.hexcolor,
|
198
|
190
|
label='Event',
|
199
|
191
|
creation_label='Event',
|
200
|
|
- available_statuses=CONTENT_DEFAULT_STATUS,
|
|
192
|
+ available_statuses=CONTENT_STATUS.allowed(),
|
201
|
193
|
)
|
202
|
194
|
|
203
|
195
|
# TODO - G.M - 31-05-2018 - Set Better Event params
|
|
@@ -207,7 +199,7 @@ comment_type = NewContentType(
|
207
|
199
|
hexcolor=thread.hexcolor,
|
208
|
200
|
label='Comment',
|
209
|
201
|
creation_label='Comment',
|
210
|
|
- available_statuses=CONTENT_DEFAULT_STATUS,
|
|
202
|
+ available_statuses=CONTENT_STATUS.allowed(),
|
211
|
203
|
)
|
212
|
204
|
|
213
|
205
|
CONTENT_DEFAULT_TYPE_SPECIAL = [
|