wbwriter 1.48.0__tar.gz → 1.49.1__tar.gz

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.
Files changed (76) hide show
  1. {wbwriter-1.48.0 → wbwriter-1.49.1}/PKG-INFO +1 -1
  2. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/article.py +5 -4
  3. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/serializers/article.py +3 -0
  4. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/article.py +8 -6
  5. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/display/article.py +3 -15
  6. {wbwriter-1.48.0 → wbwriter-1.49.1}/.gitignore +0 -0
  7. {wbwriter-1.48.0 → wbwriter-1.49.1}/pyproject.toml +0 -0
  8. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/__init__.py +0 -0
  9. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/admin.py +0 -0
  10. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/apps.py +0 -0
  11. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/dynamic_preferences_registry.py +0 -0
  12. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/factories/__init__.py +0 -0
  13. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/factories/article.py +0 -0
  14. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/factories/meta_information.py +0 -0
  15. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/filters/__init__.py +0 -0
  16. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/filters/article.py +0 -0
  17. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/filters/metainformationinstance.py +0 -0
  18. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/migrations/0001_initial_squashed_squashed_0008_alter_article_author_alter_article_feedback_contact_and_more.py +0 -0
  19. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/migrations/0009_dependantarticle.py +0 -0
  20. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/migrations/0010_alter_article_options.py +0 -0
  21. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/migrations/0011_auto_20240103_0953.py +0 -0
  22. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/migrations/0012_i18n.py +0 -0
  23. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/migrations/__init__.py +0 -0
  24. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/__init__.py +0 -0
  25. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/article_type.py +0 -0
  26. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/block.py +0 -0
  27. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/block_parameter.py +0 -0
  28. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/in_editor_template.py +0 -0
  29. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/meta_information.py +0 -0
  30. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/mixins.py +0 -0
  31. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/publication_models.py +0 -0
  32. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/style.py +0 -0
  33. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/models/template.py +0 -0
  34. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/pdf_generator.py +0 -0
  35. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/publication_parser.py +0 -0
  36. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/serializers/__init__.py +0 -0
  37. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/serializers/article_type.py +0 -0
  38. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/serializers/in_editor_template.py +0 -0
  39. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/serializers/meta_information.py +0 -0
  40. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/serializers/publication.py +0 -0
  41. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/templates/wbwriter/article_pdf.html +0 -0
  42. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/templates/wbwriter/templatetags/cite_article.html +0 -0
  43. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/templates/wbwriter/templatetags/table_of_contents.html +0 -0
  44. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/templates/wbwriter/templatetags/table_of_contents_articles.html +0 -0
  45. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/templatetags/__init__.py +0 -0
  46. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/templatetags/writer.py +0 -0
  47. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/tests/__init__.py +0 -0
  48. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/tests/conftest.py +0 -0
  49. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/tests/signals.py +0 -0
  50. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/tests/test_filter.py +0 -0
  51. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/tests/test_model.py +0 -0
  52. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/tests/test_writer.py +0 -0
  53. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/tests/tests.py +0 -0
  54. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/typings.py +0 -0
  55. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/urls.py +0 -0
  56. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/__init__.py +0 -0
  57. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/article_type.py +0 -0
  58. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/buttons.py +0 -0
  59. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/display/__init__.py +0 -0
  60. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/display/article_type.py +0 -0
  61. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/display/in_editor_template.py +0 -0
  62. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/display/meta_information.py +0 -0
  63. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/display/meta_information_instance.py +0 -0
  64. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/display/publication.py +0 -0
  65. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/documentation/article.md +0 -0
  66. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/endpoints/__init__.py +0 -0
  67. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/endpoints/article.py +0 -0
  68. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/endpoints/meta_information.py +0 -0
  69. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/in_editor_template.py +0 -0
  70. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/menu.py +0 -0
  71. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/meta_information.py +0 -0
  72. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/meta_information_instance.py +0 -0
  73. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/publication.py +0 -0
  74. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/titles/__init__.py +0 -0
  75. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/titles/publication_title_config.py +0 -0
  76. {wbwriter-1.48.0 → wbwriter-1.49.1}/wbwriter/viewsets/titles/reviewer_article_title_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbwriter
3
- Version: 1.48.0
3
+ Version: 1.49.1
4
4
  Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
5
5
  Requires-Dist: pillow==9.1.*
6
6
  Requires-Dist: reportlab==3.*
@@ -13,6 +13,7 @@ from django.core.files.base import ContentFile
13
13
  from django.db import models
14
14
  from django.db.models import Count, Max, OuterRef, Subquery
15
15
  from django.db.models.functions import Coalesce
16
+ from django.utils.translation import gettext_lazy
16
17
  from django_fsm import FSMField, transition
17
18
  from dynamic_preferences.registries import global_preferences_registry
18
19
  from modeltrans.fields import TranslationField
@@ -771,14 +772,14 @@ class Article(CloneMixin, TagModelMixin, PublishableMixin, WBModel):
771
772
  """Allow only one-off and deep-dive articles to be published."""
772
773
  errors = dict()
773
774
  if self.status not in [self.Status.APPROVED, self.Status.PUBLISHED]:
774
- errors["status"] = "Status needs to be approved in order to allow publication"
775
+ errors["status"] = [gettext_lazy("Status needs to be approved in order to allow publication")]
775
776
  if not self.type or self.type.slug not in [
776
777
  "one-off-article",
777
778
  "deep-dive-article",
778
779
  "mid-year-review",
779
780
  "year-s-favorites",
780
781
  ]:
781
- errors["type"] = "unvalid type for publication"
782
+ errors["type"] = [gettext_lazy("unvalid type for publication")]
782
783
  # We ensure the article's parser can be published
783
784
  if article_type := self.type:
784
785
  for parser in article_type.parsers.all():
@@ -788,9 +789,9 @@ class Article(CloneMixin, TagModelMixin, PublishableMixin, WBModel):
788
789
  date.today(),
789
790
  ).is_valid()
790
791
  except ParserValidationException as e:
791
- errors["non_field_errors"] = ", ".join(e.errors)
792
+ errors["non_field_errors"] = e.errors
792
793
  except ModuleNotFoundError:
793
- errors["non_field_errors"] = "invalid parser"
794
+ errors["non_field_errors"] = [gettext_lazy("invalid parser")]
794
795
  return errors
795
796
 
796
797
  def can_be_published(self) -> bool:
@@ -243,6 +243,8 @@ def _get_plugin_configs(request):
243
243
  class ArticleFullModelSerializer(ArticleModelSerializer):
244
244
  """Serializes the full set of the fields of of the Article model."""
245
245
 
246
+ is_private_icon = wb_serializers.IconSelectField(read_only=True)
247
+
246
248
  author = wb_serializers.PrimaryKeyRelatedField(
247
249
  many=False,
248
250
  label="Author",
@@ -337,6 +339,7 @@ class ArticleFullModelSerializer(ArticleModelSerializer):
337
339
  model = Article
338
340
  fields = (
339
341
  "id",
342
+ "is_private_icon",
340
343
  "name",
341
344
  "title",
342
345
  "slug",
@@ -1,5 +1,5 @@
1
1
  from django.contrib.contenttypes.models import ContentType
2
- from django.db.models import Q, QuerySet
2
+ from django.db.models import Case, Q, QuerySet, Value, When
3
3
  from django.shortcuts import get_object_or_404
4
4
  from django.utils.functional import cached_property
5
5
  from rest_framework import status
@@ -9,6 +9,7 @@ from reversion.views import RevisionMixin
9
9
  from wbcore.contrib.authentication.authentication import JWTCookieAuthentication
10
10
  from wbcore.contrib.directory.models import Person
11
11
  from wbcore.contrib.i18n.viewsets import ModelTranslateMixin
12
+ from wbcore.contrib.icons import WBIcon
12
13
  from wbcore.utils.views import CloneMixin
13
14
  from wbcore.viewsets import ModelViewSet, RepresentationViewSet
14
15
 
@@ -106,7 +107,9 @@ class ArticleModelViewSet(
106
107
  # LIST_DOCUMENTATION = "wbwriter/viewsets/documentation/article.md"
107
108
 
108
109
  serializer_class = ArticleFullModelSerializer
109
- queryset = Article.objects.all()
110
+ queryset = Article.objects.annotate(
111
+ is_private_icon=Case(When(is_private=False, then=Value(WBIcon.VIEW.icon)), default=Value(WBIcon.IGNORE.icon))
112
+ )
110
113
 
111
114
  button_config_class = ArticleModelButtonConfig
112
115
  display_config_class = ArticleDisplayConfig
@@ -139,10 +142,9 @@ class ArticleModelViewSet(
139
142
  return ContentType.objects.get(app_label="wbwriter", model="article")
140
143
 
141
144
  def get_queryset(self):
142
- if self.request.user.has_perm("wbwriter.administrate_article") or self.profile.is_internal:
143
- qs = Article.objects.all()
144
- else:
145
- qs = Article.objects.filter(is_private=False)
145
+ qs = super().get_queryset()
146
+ if not self.request.user.has_perm("wbwriter.administrate_article") and not self.profile.is_internal:
147
+ qs = qs.filter(is_private=False)
146
148
  return qs.select_related(
147
149
  "type", "feedback_contact", "reviewer", "peer_reviewer", "qa_reviewer", "author"
148
150
  ).prefetch_related("tags")
@@ -3,7 +3,7 @@ from typing import Optional
3
3
  from django.utils.translation import gettext as _
4
4
  from wbcore.contrib.color.enums import WBColor
5
5
  from wbcore.contrib.icons import WBIcon
6
- from wbcore.enums import Operator
6
+ from wbcore.enums import Operator, Unit
7
7
  from wbcore.metadata.configs import display as dp
8
8
  from wbcore.metadata.configs.display.instance_display import (
9
9
  Display,
@@ -264,6 +264,7 @@ class ArticleDisplayConfig(DisplayViewConfig):
264
264
  """Sets up and returns the list display for Article."""
265
265
  return dp.ListDisplay(
266
266
  fields=[
267
+ dp.Field(key="is_private_icon", label=" ", width=Unit.PIXEL(40)),
267
268
  dp.Field(key="id", label=_("ID")),
268
269
  dp.Field(key="title", label=_("Title")),
269
270
  dp.Field(key="teaser_image", label=_("Teaser image")),
@@ -330,20 +331,7 @@ class ArticleDisplayConfig(DisplayViewConfig):
330
331
  ),
331
332
  ],
332
333
  column="status",
333
- ),
334
- dp.Formatting(
335
- formatting_rules=[
336
- dp.FormattingRule(
337
- icon=WBIcon.IGNORE.icon,
338
- condition=("==", True),
339
- ),
340
- dp.FormattingRule(
341
- icon=WBIcon.VIEW.icon,
342
- condition=("==", False),
343
- ),
344
- ],
345
- column="is_private",
346
- ),
334
+ )
347
335
  ],
348
336
  legends=[
349
337
  dp.Legend(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes