wbwriter 2.2.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of wbwriter might be problematic. Click here for more details.
- wbwriter/__init__.py +1 -0
- wbwriter/admin.py +142 -0
- wbwriter/apps.py +5 -0
- wbwriter/dynamic_preferences_registry.py +15 -0
- wbwriter/factories/__init__.py +13 -0
- wbwriter/factories/article.py +181 -0
- wbwriter/factories/meta_information.py +29 -0
- wbwriter/filters/__init__.py +2 -0
- wbwriter/filters/article.py +47 -0
- wbwriter/filters/metainformationinstance.py +24 -0
- wbwriter/migrations/0001_initial_squashed_squashed_0008_alter_article_author_alter_article_feedback_contact_and_more.py +653 -0
- wbwriter/migrations/0009_dependantarticle.py +41 -0
- wbwriter/migrations/0010_alter_article_options.py +20 -0
- wbwriter/migrations/0011_auto_20240103_0953.py +39 -0
- wbwriter/migrations/__init__.py +0 -0
- wbwriter/models/__init__.py +9 -0
- wbwriter/models/article.py +1179 -0
- wbwriter/models/article_type.py +59 -0
- wbwriter/models/block.py +24 -0
- wbwriter/models/block_parameter.py +19 -0
- wbwriter/models/in_editor_template.py +102 -0
- wbwriter/models/meta_information.py +87 -0
- wbwriter/models/mixins.py +9 -0
- wbwriter/models/publication_models.py +170 -0
- wbwriter/models/style.py +13 -0
- wbwriter/models/template.py +34 -0
- wbwriter/pdf_generator.py +172 -0
- wbwriter/publication_parser.py +258 -0
- wbwriter/serializers/__init__.py +28 -0
- wbwriter/serializers/article.py +359 -0
- wbwriter/serializers/article_type.py +14 -0
- wbwriter/serializers/in_editor_template.py +37 -0
- wbwriter/serializers/meta_information.py +67 -0
- wbwriter/serializers/publication.py +82 -0
- wbwriter/templatetags/__init__.py +0 -0
- wbwriter/templatetags/writer.py +72 -0
- wbwriter/tests/__init__.py +0 -0
- wbwriter/tests/conftest.py +32 -0
- wbwriter/tests/signals.py +23 -0
- wbwriter/tests/test_filter.py +58 -0
- wbwriter/tests/test_model.py +591 -0
- wbwriter/tests/test_writer.py +38 -0
- wbwriter/tests/tests.py +18 -0
- wbwriter/typings.py +23 -0
- wbwriter/urls.py +83 -0
- wbwriter/viewsets/__init__.py +22 -0
- wbwriter/viewsets/article.py +270 -0
- wbwriter/viewsets/article_type.py +49 -0
- wbwriter/viewsets/buttons.py +61 -0
- wbwriter/viewsets/display/__init__.py +6 -0
- wbwriter/viewsets/display/article.py +404 -0
- wbwriter/viewsets/display/article_type.py +27 -0
- wbwriter/viewsets/display/in_editor_template.py +39 -0
- wbwriter/viewsets/display/meta_information.py +37 -0
- wbwriter/viewsets/display/meta_information_instance.py +28 -0
- wbwriter/viewsets/display/publication.py +55 -0
- wbwriter/viewsets/endpoints/__init__.py +2 -0
- wbwriter/viewsets/endpoints/article.py +12 -0
- wbwriter/viewsets/endpoints/meta_information.py +14 -0
- wbwriter/viewsets/in_editor_template.py +68 -0
- wbwriter/viewsets/menu.py +42 -0
- wbwriter/viewsets/meta_information.py +51 -0
- wbwriter/viewsets/meta_information_instance.py +48 -0
- wbwriter/viewsets/publication.py +117 -0
- wbwriter/viewsets/titles/__init__.py +2 -0
- wbwriter/viewsets/titles/publication_title_config.py +18 -0
- wbwriter/viewsets/titles/reviewer_article_title_config.py +6 -0
- wbwriter-2.2.1.dist-info/METADATA +8 -0
- wbwriter-2.2.1.dist-info/RECORD +70 -0
- wbwriter-2.2.1.dist-info/WHEEL +5 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from django.utils.translation import gettext as _
|
|
4
|
+
from wbcore.contrib.color.enums import WBColor
|
|
5
|
+
from wbcore.contrib.icons import WBIcon
|
|
6
|
+
from wbcore.enums import Operator
|
|
7
|
+
from wbcore.metadata.configs import display as dp
|
|
8
|
+
from wbcore.metadata.configs.display.instance_display import (
|
|
9
|
+
Display,
|
|
10
|
+
Inline,
|
|
11
|
+
Layout,
|
|
12
|
+
Page,
|
|
13
|
+
Section,
|
|
14
|
+
Style,
|
|
15
|
+
)
|
|
16
|
+
from wbcore.metadata.configs.display.instance_display.operators import default
|
|
17
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
18
|
+
from wbwriter.models import Article
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class DependantArticleDisplayConfig(DisplayViewConfig):
|
|
22
|
+
def get_list_display(self) -> dp.ListDisplay:
|
|
23
|
+
article = "dependant_article" if "article_id" in self.view.kwargs else "article"
|
|
24
|
+
return dp.ListDisplay(
|
|
25
|
+
fields=[
|
|
26
|
+
dp.Field(key=article, label=_("Article")),
|
|
27
|
+
]
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ArticleDisplayConfig(DisplayViewConfig):
|
|
32
|
+
"""Provides getter methods for the list and instance displays."""
|
|
33
|
+
|
|
34
|
+
def get_instance_display(self) -> Display:
|
|
35
|
+
using_section = Section(
|
|
36
|
+
key="using_section",
|
|
37
|
+
title=_("Uses Articles"),
|
|
38
|
+
collapsible=False,
|
|
39
|
+
display=Display(
|
|
40
|
+
pages=[
|
|
41
|
+
Page(
|
|
42
|
+
layouts={
|
|
43
|
+
default(): Layout(
|
|
44
|
+
grid_template_areas=[["dependantarticle-article"]],
|
|
45
|
+
inlines=[
|
|
46
|
+
Inline(key="dependantarticle-article", endpoint="dependantarticle-article"),
|
|
47
|
+
],
|
|
48
|
+
)
|
|
49
|
+
},
|
|
50
|
+
)
|
|
51
|
+
]
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
used_section = Section(
|
|
56
|
+
key="used_section",
|
|
57
|
+
title=_("Used in Articles"),
|
|
58
|
+
collapsible=False,
|
|
59
|
+
display=Display(
|
|
60
|
+
pages=[
|
|
61
|
+
Page(
|
|
62
|
+
layouts={
|
|
63
|
+
default(): Layout(
|
|
64
|
+
grid_template_areas=[["usedarticle-article"]],
|
|
65
|
+
inlines=[
|
|
66
|
+
Inline(key="usedarticle-article", endpoint="usedarticle-article"),
|
|
67
|
+
],
|
|
68
|
+
)
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
status_section = Section(
|
|
76
|
+
key="status_section",
|
|
77
|
+
title=_("Status"),
|
|
78
|
+
collapsible=False,
|
|
79
|
+
display=Display(
|
|
80
|
+
pages=[
|
|
81
|
+
Page(
|
|
82
|
+
title=_("Status"),
|
|
83
|
+
layouts={
|
|
84
|
+
default(): Layout(
|
|
85
|
+
grid_template_areas=[["status"]],
|
|
86
|
+
grid_template_columns="auto-fill",
|
|
87
|
+
)
|
|
88
|
+
},
|
|
89
|
+
)
|
|
90
|
+
]
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
permission_section = Section(
|
|
95
|
+
key="permission_section",
|
|
96
|
+
title=_("Author & Reviewers"),
|
|
97
|
+
collapsed=True,
|
|
98
|
+
display=Display(
|
|
99
|
+
pages=[
|
|
100
|
+
Page(
|
|
101
|
+
title=_("Author & Reviewers"),
|
|
102
|
+
layouts={
|
|
103
|
+
default(): Layout(
|
|
104
|
+
grid_template_areas=[["author", "reviewer"], ["peer_reviewer", "qa_reviewer"]],
|
|
105
|
+
grid_template_columns=[Style.fr(1), Style.fr(1)],
|
|
106
|
+
grid_auto_rows=Style.MIN_CONTENT,
|
|
107
|
+
)
|
|
108
|
+
},
|
|
109
|
+
)
|
|
110
|
+
]
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
additional_information_section = Section(
|
|
115
|
+
key="additional_information_section",
|
|
116
|
+
title=_("Additional Information"),
|
|
117
|
+
display=Display(
|
|
118
|
+
pages=[
|
|
119
|
+
Page(
|
|
120
|
+
layouts={
|
|
121
|
+
default(): Layout(
|
|
122
|
+
grid_template_areas=[["information"]],
|
|
123
|
+
inlines=[Inline(key="information", endpoint="metainformationinstance")],
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
]
|
|
128
|
+
),
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
def _get_instance_display(
|
|
132
|
+
collapsed_metadata_section: bool = False,
|
|
133
|
+
collapsed_content_section: bool = False,
|
|
134
|
+
show_is_private: bool = False,
|
|
135
|
+
show_with_additional_information: bool = False,
|
|
136
|
+
) -> Display:
|
|
137
|
+
"""Returns a display for the wbwriter instance
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
collapsed_metadata_section: Indicates whether the metadata section should be collapsed. Defaults to False.
|
|
141
|
+
collapsed_content_section: Indicates whether the content section should be collapsed. Defaults to False.
|
|
142
|
+
show_is_private: Indicates whether the is_private field should be visible. Defaults to False.
|
|
143
|
+
show_with_additional_information: Indicates whether the additional_information section should be added to the display. Defaults to False.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
Display: A display instance
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
def _metadata_section(collapsed: bool = True, show_is_private: bool = False) -> Section:
|
|
150
|
+
"""Returns the metadata section
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
collapsed: Indicates whether the section should be collapsed or not. Defaults to True.
|
|
154
|
+
show_is_private: Indicates whether the is_private field should be visible or not. Defaults to False.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
Section: A section instance
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
grid_template = [
|
|
161
|
+
["teaser_image", "type", "is_private"] if show_is_private else ["teaser_image", "type", "."],
|
|
162
|
+
["teaser_image", "name", "title"],
|
|
163
|
+
["teaser_image", "modified", "created"],
|
|
164
|
+
]
|
|
165
|
+
return Section(
|
|
166
|
+
key="metadata_section",
|
|
167
|
+
title=_("Metadata"),
|
|
168
|
+
collapsible=True,
|
|
169
|
+
collapsed=collapsed,
|
|
170
|
+
display=Display(
|
|
171
|
+
pages=[
|
|
172
|
+
Page(
|
|
173
|
+
title=_("Metadata"),
|
|
174
|
+
layouts={
|
|
175
|
+
default(): Layout(
|
|
176
|
+
grid_template_areas=grid_template,
|
|
177
|
+
grid_template_columns=[Style.MIN_CONTENT, Style.fr(1), Style.fr(1)],
|
|
178
|
+
grid_auto_rows=Style.MIN_CONTENT,
|
|
179
|
+
),
|
|
180
|
+
},
|
|
181
|
+
)
|
|
182
|
+
]
|
|
183
|
+
),
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
def _content_section(collapsed: bool) -> Section:
|
|
187
|
+
"""Returns the content section
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
collapsed: Indicates whether the section should be collapsed or not. Defaults to False.
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
Section: A section instance
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
return Section(
|
|
197
|
+
key="content_section",
|
|
198
|
+
title=_("Content & Tags"),
|
|
199
|
+
collapsed=collapsed,
|
|
200
|
+
display=Display(
|
|
201
|
+
pages=[
|
|
202
|
+
Page(
|
|
203
|
+
title=_("Content & Tags"),
|
|
204
|
+
layouts={
|
|
205
|
+
default(): Layout(
|
|
206
|
+
grid_template_areas=[["tags"], ["content"]],
|
|
207
|
+
grid_template_columns=[Style.fr(1)],
|
|
208
|
+
grid_auto_rows=Style.MIN_CONTENT,
|
|
209
|
+
),
|
|
210
|
+
},
|
|
211
|
+
)
|
|
212
|
+
]
|
|
213
|
+
),
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
sections = [
|
|
217
|
+
status_section,
|
|
218
|
+
_metadata_section(collapsed_metadata_section, show_is_private),
|
|
219
|
+
_content_section(collapsed_content_section),
|
|
220
|
+
permission_section,
|
|
221
|
+
used_section,
|
|
222
|
+
using_section,
|
|
223
|
+
]
|
|
224
|
+
grid_template = [
|
|
225
|
+
["status_section", "status_section"],
|
|
226
|
+
["metadata_section", "metadata_section"],
|
|
227
|
+
["content_section", "content_section"],
|
|
228
|
+
["permission_section", "permission_section"],
|
|
229
|
+
["using_section", "used_section"],
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
if show_with_additional_information:
|
|
233
|
+
sections.append(additional_information_section)
|
|
234
|
+
grid_template.append(["additional_information_section", "additional_information_section"])
|
|
235
|
+
|
|
236
|
+
return Display(
|
|
237
|
+
pages=[
|
|
238
|
+
Page(
|
|
239
|
+
title=_("General Information"),
|
|
240
|
+
layouts={
|
|
241
|
+
default(): Layout(
|
|
242
|
+
grid_template_areas=grid_template,
|
|
243
|
+
grid_auto_rows=Style.MIN_CONTENT,
|
|
244
|
+
sections=sections,
|
|
245
|
+
),
|
|
246
|
+
},
|
|
247
|
+
),
|
|
248
|
+
]
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
if self.view.kwargs.get("pk"):
|
|
252
|
+
obj: Article = self.view.get_object()
|
|
253
|
+
if obj.status in [Article.Status.APPROVED, Article.Status.PUBLISHED]:
|
|
254
|
+
if self.request.user.has_perm("wbwriter.administrate_article"):
|
|
255
|
+
return _get_instance_display(
|
|
256
|
+
collapsed_content_section=True, show_is_private=True, show_with_additional_information=True
|
|
257
|
+
)
|
|
258
|
+
return _get_instance_display(collapsed_content_section=True)
|
|
259
|
+
return _get_instance_display(collapsed_metadata_section=True)
|
|
260
|
+
return _get_instance_display()
|
|
261
|
+
|
|
262
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
263
|
+
"""Sets up and returns the list display for Article."""
|
|
264
|
+
return dp.ListDisplay(
|
|
265
|
+
fields=[
|
|
266
|
+
dp.Field(key="id", label=_("ID")),
|
|
267
|
+
dp.Field(key="title", label=_("Title")),
|
|
268
|
+
dp.Field(key="teaser_image", label=_("Teaser image")),
|
|
269
|
+
dp.Field(key="type", label=_("Type")),
|
|
270
|
+
dp.Field(key="modified", label=_("Last Modification Date")),
|
|
271
|
+
dp.Field(key="created", label=_("Creation Date")),
|
|
272
|
+
dp.Field(key="tags", label=_("Tags")),
|
|
273
|
+
dp.Field(key="author", label=_("Author")),
|
|
274
|
+
dp.Field(key="reviewer", label=_("Reviewer")),
|
|
275
|
+
dp.Field(key="peer_reviewer", label=_("Peer Reviewer")),
|
|
276
|
+
dp.Field(key="qa_reviewer", label=_("QA Reviewer")),
|
|
277
|
+
],
|
|
278
|
+
formatting=[
|
|
279
|
+
dp.Formatting(
|
|
280
|
+
formatting_rules=[
|
|
281
|
+
dp.FormattingRule(
|
|
282
|
+
style={"backgroundColor": WBColor.YELLOW.value},
|
|
283
|
+
condition=dp.Condition(
|
|
284
|
+
operator=Operator.EQUAL,
|
|
285
|
+
value=Article.Status.DRAFT,
|
|
286
|
+
),
|
|
287
|
+
),
|
|
288
|
+
dp.FormattingRule(
|
|
289
|
+
style={"backgroundColor": WBColor.RED_DARK.value},
|
|
290
|
+
condition=dp.Condition(
|
|
291
|
+
operator=Operator.EQUAL,
|
|
292
|
+
value=Article.Status.FEEDBACK,
|
|
293
|
+
),
|
|
294
|
+
),
|
|
295
|
+
dp.FormattingRule(
|
|
296
|
+
style={"backgroundColor": WBColor.BLUE_LIGHT.value},
|
|
297
|
+
condition=dp.Condition(
|
|
298
|
+
operator=Operator.EQUAL,
|
|
299
|
+
value=Article.Status.PEER_REVIEW,
|
|
300
|
+
),
|
|
301
|
+
),
|
|
302
|
+
dp.FormattingRule(
|
|
303
|
+
style={"backgroundColor": WBColor.BLUE.value},
|
|
304
|
+
condition=dp.Condition(
|
|
305
|
+
operator=Operator.EQUAL,
|
|
306
|
+
value=Article.Status.QA_REVIEW,
|
|
307
|
+
),
|
|
308
|
+
),
|
|
309
|
+
dp.FormattingRule(
|
|
310
|
+
style={"backgroundColor": WBColor.GREEN_LIGHT.value},
|
|
311
|
+
condition=dp.Condition(
|
|
312
|
+
operator=Operator.EQUAL,
|
|
313
|
+
value=Article.Status.AUTHOR_APPROVAL,
|
|
314
|
+
),
|
|
315
|
+
),
|
|
316
|
+
dp.FormattingRule(
|
|
317
|
+
style={"backgroundColor": WBColor.GREEN.value},
|
|
318
|
+
condition=dp.Condition(
|
|
319
|
+
operator=Operator.EQUAL,
|
|
320
|
+
value=Article.Status.APPROVED,
|
|
321
|
+
),
|
|
322
|
+
),
|
|
323
|
+
dp.FormattingRule(
|
|
324
|
+
style={"backgroundColor": WBColor.GREEN_DARK.value},
|
|
325
|
+
condition=dp.Condition(
|
|
326
|
+
operator=Operator.EQUAL,
|
|
327
|
+
value=Article.Status.PUBLISHED,
|
|
328
|
+
),
|
|
329
|
+
),
|
|
330
|
+
],
|
|
331
|
+
column="status",
|
|
332
|
+
),
|
|
333
|
+
dp.Formatting(
|
|
334
|
+
formatting_rules=[
|
|
335
|
+
dp.FormattingRule(
|
|
336
|
+
icon=WBIcon.IGNORE.icon,
|
|
337
|
+
condition=("==", True),
|
|
338
|
+
),
|
|
339
|
+
dp.FormattingRule(
|
|
340
|
+
icon=WBIcon.VIEW.icon,
|
|
341
|
+
condition=("==", False),
|
|
342
|
+
),
|
|
343
|
+
],
|
|
344
|
+
column="is_private",
|
|
345
|
+
),
|
|
346
|
+
],
|
|
347
|
+
legends=[
|
|
348
|
+
dp.Legend(
|
|
349
|
+
key="status",
|
|
350
|
+
items=[
|
|
351
|
+
dp.LegendItem(
|
|
352
|
+
value=Article.Status.FEEDBACK.value,
|
|
353
|
+
label=Article.Status.FEEDBACK.label,
|
|
354
|
+
icon=WBColor.RED_DARK.value,
|
|
355
|
+
),
|
|
356
|
+
dp.LegendItem(
|
|
357
|
+
value=Article.Status.DRAFT.value,
|
|
358
|
+
label=Article.Status.DRAFT.label,
|
|
359
|
+
icon=WBColor.YELLOW.value,
|
|
360
|
+
),
|
|
361
|
+
dp.LegendItem(
|
|
362
|
+
value=Article.Status.PEER_REVIEW.value,
|
|
363
|
+
label=Article.Status.PEER_REVIEW.label,
|
|
364
|
+
icon=WBColor.BLUE_LIGHT.value,
|
|
365
|
+
),
|
|
366
|
+
dp.LegendItem(
|
|
367
|
+
value=Article.Status.QA_REVIEW.value,
|
|
368
|
+
label=Article.Status.QA_REVIEW.label,
|
|
369
|
+
icon=WBColor.BLUE.value,
|
|
370
|
+
),
|
|
371
|
+
dp.LegendItem(
|
|
372
|
+
value=Article.Status.AUTHOR_APPROVAL.value,
|
|
373
|
+
label=Article.Status.AUTHOR_APPROVAL.label,
|
|
374
|
+
icon=WBColor.GREEN_LIGHT.value,
|
|
375
|
+
),
|
|
376
|
+
dp.LegendItem(
|
|
377
|
+
value=Article.Status.APPROVED.value,
|
|
378
|
+
label=Article.Status.APPROVED.label,
|
|
379
|
+
icon=WBColor.GREEN.value,
|
|
380
|
+
),
|
|
381
|
+
dp.LegendItem(
|
|
382
|
+
value=Article.Status.PUBLISHED.value,
|
|
383
|
+
label=Article.Status.PUBLISHED.label,
|
|
384
|
+
icon=WBColor.GREEN_DARK.value,
|
|
385
|
+
),
|
|
386
|
+
],
|
|
387
|
+
),
|
|
388
|
+
dp.Legend(
|
|
389
|
+
key="is_private",
|
|
390
|
+
items=[
|
|
391
|
+
dp.LegendItem(
|
|
392
|
+
value=False,
|
|
393
|
+
label=_("Public"),
|
|
394
|
+
icon=WBIcon.VIEW.icon,
|
|
395
|
+
),
|
|
396
|
+
dp.LegendItem(
|
|
397
|
+
value=True,
|
|
398
|
+
label=_("Private"),
|
|
399
|
+
icon=WBIcon.IGNORE.icon,
|
|
400
|
+
),
|
|
401
|
+
],
|
|
402
|
+
),
|
|
403
|
+
],
|
|
404
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from wbcore.metadata.configs import display as dp
|
|
4
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
5
|
+
Display,
|
|
6
|
+
create_simple_display,
|
|
7
|
+
)
|
|
8
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ArticleTypeDisplayConfig(DisplayViewConfig):
|
|
12
|
+
"""Provides getter methods for the list and instance displays."""
|
|
13
|
+
|
|
14
|
+
def get_instance_display(self) -> Display:
|
|
15
|
+
return create_simple_display([["label"]])
|
|
16
|
+
|
|
17
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
18
|
+
"""Sets up and returns the list display for ArticleType."""
|
|
19
|
+
return dp.ListDisplay(
|
|
20
|
+
fields=[
|
|
21
|
+
dp.Field(key="id", label="ID"),
|
|
22
|
+
dp.Field(key="label", label="Label"),
|
|
23
|
+
dp.Field(key="slug", label="Slug"),
|
|
24
|
+
],
|
|
25
|
+
formatting=[],
|
|
26
|
+
legends=[],
|
|
27
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from wbcore.metadata.configs import display as dp
|
|
4
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
5
|
+
Display,
|
|
6
|
+
create_simple_display,
|
|
7
|
+
)
|
|
8
|
+
from wbcore.metadata.configs.display.instance_display.utils import repeat_field
|
|
9
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class InEditorTemplateDisplayConfig(DisplayViewConfig):
|
|
13
|
+
"""Provides getter methods for the list and instance displays."""
|
|
14
|
+
|
|
15
|
+
def get_instance_display(self) -> Display:
|
|
16
|
+
return create_simple_display(
|
|
17
|
+
[
|
|
18
|
+
["uuid", "title"],
|
|
19
|
+
["style", "template"],
|
|
20
|
+
["modified", "is_stand_alone_template"],
|
|
21
|
+
[repeat_field(2, "description")],
|
|
22
|
+
]
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
26
|
+
"""Sets up and returns the list display for InEditorTemplate."""
|
|
27
|
+
return dp.ListDisplay(
|
|
28
|
+
fields=[
|
|
29
|
+
dp.Field(key="uuid", label="UUID"),
|
|
30
|
+
dp.Field(key="title", label="Title"),
|
|
31
|
+
dp.Field(key="description", label="Description"),
|
|
32
|
+
# dp.Field(key="style", label="Style"),
|
|
33
|
+
# dp.Field(key="template", label="Template"),
|
|
34
|
+
dp.Field(key="modified", label="Last modified"),
|
|
35
|
+
dp.Field(key="is_stand_alone_template", label="Is a Stand-Alone Template"),
|
|
36
|
+
],
|
|
37
|
+
formatting=[],
|
|
38
|
+
legends=[],
|
|
39
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from wbcore.metadata.configs import display as dp
|
|
4
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
5
|
+
Display,
|
|
6
|
+
create_simple_display,
|
|
7
|
+
)
|
|
8
|
+
from wbcore.metadata.configs.display.instance_display.utils import repeat_field
|
|
9
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MetaInformationDisplayConfig(DisplayViewConfig):
|
|
13
|
+
"""Provides getter methods for the list and instance displays."""
|
|
14
|
+
|
|
15
|
+
def get_instance_display(self) -> Display:
|
|
16
|
+
return create_simple_display(
|
|
17
|
+
[
|
|
18
|
+
[repeat_field(2, "article_type")],
|
|
19
|
+
["name", "key"],
|
|
20
|
+
["meta_information_type", "boolean_default"],
|
|
21
|
+
]
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
25
|
+
"""Sets up and returns the list display for MetaInformation."""
|
|
26
|
+
return dp.ListDisplay(
|
|
27
|
+
fields=[
|
|
28
|
+
dp.Field(key="id", label="ID"),
|
|
29
|
+
dp.Field(key="article_type", label="Article Type"),
|
|
30
|
+
dp.Field(key="name", label="Name"),
|
|
31
|
+
dp.Field(key="key", label="Key"),
|
|
32
|
+
dp.Field(key="meta_information_type", label="Meta Information Type"),
|
|
33
|
+
dp.Field(key="boolean_default", label="Boolean Default"),
|
|
34
|
+
],
|
|
35
|
+
formatting=[],
|
|
36
|
+
legends=[],
|
|
37
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from wbcore.metadata.configs import display as dp
|
|
4
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
5
|
+
Display,
|
|
6
|
+
create_simple_display,
|
|
7
|
+
)
|
|
8
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MetaInformationInstanceDisplayConfig(DisplayViewConfig):
|
|
12
|
+
"""Provides getter methods for the list and instance displays."""
|
|
13
|
+
|
|
14
|
+
def get_instance_display(self) -> Display:
|
|
15
|
+
return create_simple_display([["meta_information", "boolean_value"]])
|
|
16
|
+
|
|
17
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
18
|
+
"""Sets up and returns the list display for MetaInformationInstance."""
|
|
19
|
+
return dp.ListDisplay(
|
|
20
|
+
fields=[
|
|
21
|
+
# dp.Field(key="id", label="ID"),
|
|
22
|
+
# dp.Field(key="article", label="Article"),
|
|
23
|
+
dp.Field(key="meta_information", label="Meta Information"),
|
|
24
|
+
dp.Field(key="boolean_value", label="Boolean Value"),
|
|
25
|
+
],
|
|
26
|
+
formatting=[],
|
|
27
|
+
legends=[],
|
|
28
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from wbcore.metadata.configs import display as dp
|
|
4
|
+
from wbcore.metadata.configs.display.instance_display.shortcuts import (
|
|
5
|
+
Display,
|
|
6
|
+
create_simple_display,
|
|
7
|
+
)
|
|
8
|
+
from wbcore.metadata.configs.display.instance_display.utils import repeat_field
|
|
9
|
+
from wbcore.metadata.configs.display.view_config import DisplayViewConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class PublicationDisplayConfig(DisplayViewConfig):
|
|
13
|
+
"""Provides getter methods for the list and instance displays."""
|
|
14
|
+
|
|
15
|
+
def get_instance_display(self) -> Display:
|
|
16
|
+
return create_simple_display(
|
|
17
|
+
[
|
|
18
|
+
["title", "author"],
|
|
19
|
+
["created", "modified"],
|
|
20
|
+
[repeat_field(2, "teaser_image")],
|
|
21
|
+
[repeat_field(2, "description")],
|
|
22
|
+
]
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
26
|
+
"""Sets up and returns the list display for Publication."""
|
|
27
|
+
return dp.ListDisplay(
|
|
28
|
+
fields=[
|
|
29
|
+
dp.Field(key="title", label="Title"),
|
|
30
|
+
dp.Field(key="author", label="Author"),
|
|
31
|
+
dp.Field(key="modified", label="Modified"),
|
|
32
|
+
dp.Field(key="created", label="Created"),
|
|
33
|
+
dp.Field(key="teaser_image", label="Teaser image"),
|
|
34
|
+
],
|
|
35
|
+
formatting=[],
|
|
36
|
+
legends=[],
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class PublicationParserDisplayConfig(DisplayViewConfig):
|
|
41
|
+
"""Provides getter methods for the list and instance displays."""
|
|
42
|
+
|
|
43
|
+
def get_instance_display(self) -> Display:
|
|
44
|
+
return create_simple_display([["title", "parser_path"]])
|
|
45
|
+
|
|
46
|
+
def get_list_display(self) -> Optional[dp.ListDisplay]:
|
|
47
|
+
"""Sets up and returns the list display for Publication Parser."""
|
|
48
|
+
return dp.ListDisplay(
|
|
49
|
+
fields=[
|
|
50
|
+
dp.Field(key="title", label="Title"),
|
|
51
|
+
dp.Field(key="parser_path", label="Parser Path"),
|
|
52
|
+
],
|
|
53
|
+
formatting=[],
|
|
54
|
+
legends=[],
|
|
55
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from rest_framework.reverse import reverse
|
|
2
|
+
from wbcore.metadata.configs.endpoints import EndpointViewConfig
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class DependantArticleEndpointViewConfig(EndpointViewConfig):
|
|
6
|
+
def _get_instance_endpoint(self, **kwargs):
|
|
7
|
+
return "{{dependant_article_url}}" if "article_id" in self.view.kwargs else "{{article_url}}"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ReviewerArticleModelEndpointConfig(EndpointViewConfig):
|
|
11
|
+
def get_list_endpoint(self, **kwargs):
|
|
12
|
+
return reverse("wbwriter:review-article-list", args=[], request=self.request)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from rest_framework.reverse import reverse
|
|
2
|
+
from wbcore.metadata.configs.endpoints import EndpointViewConfig
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class MetaInformationInstanceEndpointConfig(EndpointViewConfig):
|
|
6
|
+
def get_create_endpoint(self, **kwargs):
|
|
7
|
+
return None
|
|
8
|
+
|
|
9
|
+
def get_endpoint(self, **kwargs):
|
|
10
|
+
if article_id := self.view.kwargs.get("article_id", None):
|
|
11
|
+
return reverse(
|
|
12
|
+
"wbwriter:metainformationinstancearticle-list", kwargs={"article_id": article_id}, request=self.request
|
|
13
|
+
)
|
|
14
|
+
return reverse("wbwriter:metainformationinstance-list", request=self.request)
|