wbwriter 1.46.14__tar.gz → 1.47.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.
Potentially problematic release.
This version of wbwriter might be problematic. Click here for more details.
- {wbwriter-1.46.14 → wbwriter-1.47.1}/PKG-INFO +1 -1
- wbwriter-1.47.1/wbwriter/migrations/0012_i18n.py +24 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/article.py +15 -1
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/publication_models.py +3 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/serializers/article.py +7 -2
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/tests/test_model.py +4 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/article.py +4 -1
- {wbwriter-1.46.14 → wbwriter-1.47.1}/.gitignore +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/pyproject.toml +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/admin.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/apps.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/dynamic_preferences_registry.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/factories/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/factories/article.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/factories/meta_information.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/filters/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/filters/article.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/filters/metainformationinstance.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/migrations/0001_initial_squashed_squashed_0008_alter_article_author_alter_article_feedback_contact_and_more.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/migrations/0009_dependantarticle.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/migrations/0010_alter_article_options.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/migrations/0011_auto_20240103_0953.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/migrations/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/article_type.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/block.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/block_parameter.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/in_editor_template.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/meta_information.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/mixins.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/style.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/models/template.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/pdf_generator.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/publication_parser.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/serializers/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/serializers/article_type.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/serializers/in_editor_template.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/serializers/meta_information.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/serializers/publication.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templates/wbwriter/article_pdf.html +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templates/wbwriter/templatetags/cite_article.html +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templates/wbwriter/templatetags/table_of_contents.html +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templates/wbwriter/templatetags/table_of_contents_articles.html +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templatetags/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templatetags/writer.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/tests/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/tests/conftest.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/tests/signals.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/tests/test_filter.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/tests/test_writer.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/tests/tests.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/typings.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/urls.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/article_type.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/buttons.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/display/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/display/article.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/display/article_type.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/display/in_editor_template.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/display/meta_information.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/display/meta_information_instance.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/display/publication.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/documentation/article.md +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/endpoints/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/endpoints/article.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/endpoints/meta_information.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/in_editor_template.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/menu.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/meta_information.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/meta_information_instance.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/publication.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/titles/__init__.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/titles/publication_title_config.py +0 -0
- {wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/titles/reviewer_article_title_config.py +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Generated by Django 5.0.12 on 2025-03-03 10:28
|
|
2
|
+
|
|
3
|
+
import modeltrans.fields
|
|
4
|
+
from django.db import migrations
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
('wbwriter', '0011_auto_20240103_0953'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.AddField(
|
|
15
|
+
model_name='article',
|
|
16
|
+
name='i18n',
|
|
17
|
+
field=modeltrans.fields.TranslationField(fields=['title', 'content', 'slug'], required_languages=(), virtual_fields=True),
|
|
18
|
+
),
|
|
19
|
+
migrations.AddField(
|
|
20
|
+
model_name='publication',
|
|
21
|
+
name='i18n',
|
|
22
|
+
field=modeltrans.fields.TranslationField(fields=['title', 'slug', 'content'], required_languages=(), virtual_fields=True),
|
|
23
|
+
),
|
|
24
|
+
]
|
|
@@ -2,6 +2,7 @@ import datetime
|
|
|
2
2
|
import json
|
|
3
3
|
import re
|
|
4
4
|
from contextlib import suppress
|
|
5
|
+
from copy import deepcopy
|
|
5
6
|
from datetime import date, timedelta
|
|
6
7
|
|
|
7
8
|
from celery import shared_task
|
|
@@ -14,10 +15,12 @@ from django.db.models import Count, Max, OuterRef, Subquery
|
|
|
14
15
|
from django.db.models.functions import Coalesce
|
|
15
16
|
from django_fsm import FSMField, transition
|
|
16
17
|
from dynamic_preferences.registries import global_preferences_registry
|
|
18
|
+
from modeltrans.fields import TranslationField
|
|
17
19
|
from rest_framework.reverse import reverse
|
|
18
20
|
from slugify import slugify
|
|
19
21
|
from wbcore.contrib.directory.models import Person
|
|
20
22
|
from wbcore.contrib.documents.models import Document, DocumentType
|
|
23
|
+
from wbcore.contrib.i18n.translation import translate_string
|
|
21
24
|
from wbcore.contrib.icons import WBIcon
|
|
22
25
|
from wbcore.contrib.notifications.dispatch import send_notification
|
|
23
26
|
from wbcore.contrib.notifications.utils import create_notification_type
|
|
@@ -418,6 +421,17 @@ class Article(TagModelMixin, PublishableMixin, WBModel):
|
|
|
418
421
|
null=False,
|
|
419
422
|
)
|
|
420
423
|
|
|
424
|
+
i18n = TranslationField(fields=["title", "content", "slug"])
|
|
425
|
+
|
|
426
|
+
def _translate_content(self, to_language: str) -> dict:
|
|
427
|
+
new_content = deepcopy(self.content)
|
|
428
|
+
for section_key in new_content.get("sections", {}):
|
|
429
|
+
for content_key, content_value in new_content["sections"][section_key]["content"].items():
|
|
430
|
+
new_content["sections"][section_key]["content"][content_key] = translate_string(
|
|
431
|
+
content_value, to_language
|
|
432
|
+
)
|
|
433
|
+
return new_content
|
|
434
|
+
|
|
421
435
|
type = models.ForeignKey(
|
|
422
436
|
"wbwriter.ArticleType",
|
|
423
437
|
related_name="article",
|
|
@@ -1074,7 +1088,7 @@ class Article(TagModelMixin, PublishableMixin, WBModel):
|
|
|
1074
1088
|
template_context["content"] = f"""
|
|
1075
1089
|
<p>To generate the PDF, please correct the following errors:</p>
|
|
1076
1090
|
<ul>
|
|
1077
|
-
{
|
|
1091
|
+
{"".join([f"<li>{error}</li>" for error in parser.errors])}
|
|
1078
1092
|
</ul>
|
|
1079
1093
|
"""
|
|
1080
1094
|
html = template.Template(empty_template).render(template_context)
|
|
@@ -5,6 +5,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey
|
|
|
5
5
|
from django.contrib.contenttypes.models import ContentType
|
|
6
6
|
from django.db import models
|
|
7
7
|
from django.utils.functional import cached_property
|
|
8
|
+
from modeltrans.fields import TranslationField
|
|
8
9
|
from rest_framework.reverse import reverse
|
|
9
10
|
from slugify import slugify
|
|
10
11
|
from wbcore.contrib.tags.models import TagModelMixin
|
|
@@ -62,6 +63,8 @@ class Publication(TagModelMixin, models.Model):
|
|
|
62
63
|
null=True,
|
|
63
64
|
)
|
|
64
65
|
|
|
66
|
+
i18n = TranslationField(fields=["title", "slug", "content"])
|
|
67
|
+
|
|
65
68
|
parser = models.ForeignKey(
|
|
66
69
|
"wbwriter.PublicationParser",
|
|
67
70
|
related_name="parsed_publication",
|
|
@@ -58,7 +58,10 @@ class DependantArticleModelSerializer(ModelSerializer):
|
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
from wbcore.contrib.i18n.serializers.mixins import ModelTranslateSerializerMixin
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ArticleModelSerializer(ModelTranslateSerializerMixin, TagSerializerMixin, ModelSerializer):
|
|
62
65
|
"""Serializes a subset of the fields of of the Article model to minimize
|
|
63
66
|
workload on serializing lists of instances.
|
|
64
67
|
"""
|
|
@@ -81,7 +84,7 @@ class ArticleModelSerializer(TagSerializerMixin, ModelSerializer):
|
|
|
81
84
|
@register_resource()
|
|
82
85
|
def metainformationinstance(self, instance, request, user):
|
|
83
86
|
return {
|
|
84
|
-
"metainformationinstance": f
|
|
87
|
+
"metainformationinstance": f"{reverse('wbwriter:metainformationinstancearticle-list', args=[instance.id], request=request)}",
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
@register_resource()
|
|
@@ -162,6 +165,7 @@ class ArticleModelSerializer(TagSerializerMixin, ModelSerializer):
|
|
|
162
165
|
"tags",
|
|
163
166
|
"_tags",
|
|
164
167
|
"_additional_resources",
|
|
168
|
+
"_i18n",
|
|
165
169
|
)
|
|
166
170
|
|
|
167
171
|
|
|
@@ -357,4 +361,5 @@ class ArticleFullModelSerializer(ArticleModelSerializer):
|
|
|
357
361
|
"tags",
|
|
358
362
|
"_tags",
|
|
359
363
|
"_additional_resources",
|
|
364
|
+
"_i18n",
|
|
360
365
|
)
|
|
@@ -556,7 +556,11 @@ class TestArticleCloning:
|
|
|
556
556
|
del article_clone_dict["teaser_image"]
|
|
557
557
|
article_dict["name"] += "_clone"
|
|
558
558
|
article_dict["slug"] += "-clone"
|
|
559
|
+
article_dict["slug_en_us"] += "-clone"
|
|
560
|
+
article_dict["slug_i18n"] += "-clone"
|
|
559
561
|
article_dict["title"] += " (Clone)"
|
|
562
|
+
article_dict["title_i18n"] += " (Clone)"
|
|
563
|
+
article_dict["title_en_us"] += " (Clone)"
|
|
560
564
|
article_dict["author"] = user.profile.id
|
|
561
565
|
assert article_dict == article_clone_dict
|
|
562
566
|
assert Article.objects.count() == 4
|
|
@@ -8,6 +8,7 @@ from rest_framework.response import Response
|
|
|
8
8
|
from reversion.views import RevisionMixin
|
|
9
9
|
from wbcore.contrib.authentication.authentication import JWTCookieAuthentication
|
|
10
10
|
from wbcore.contrib.directory.models import Person
|
|
11
|
+
from wbcore.contrib.i18n.viewsets import ModelTranslateMixin
|
|
11
12
|
from wbcore.utils.views import CloneMixin
|
|
12
13
|
from wbcore.viewsets import ModelViewSet, RepresentationViewSet
|
|
13
14
|
|
|
@@ -99,7 +100,9 @@ class ArticleInstancePermissionMixin:
|
|
|
99
100
|
return False
|
|
100
101
|
|
|
101
102
|
|
|
102
|
-
class ArticleModelViewSet(
|
|
103
|
+
class ArticleModelViewSet(
|
|
104
|
+
ModelTranslateMixin, ArticleInstancePermissionMixin, CloneMixin, RevisionMixin, ModelViewSet
|
|
105
|
+
):
|
|
103
106
|
# LIST_DOCUMENTATION = "wbwriter/viewsets/documentation/article.md"
|
|
104
107
|
|
|
105
108
|
serializer_class = ArticleFullModelSerializer
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templates/wbwriter/templatetags/cite_article.html
RENAMED
|
File without changes
|
{wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/templates/wbwriter/templatetags/table_of_contents.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wbwriter-1.46.14 → wbwriter-1.47.1}/wbwriter/viewsets/titles/reviewer_article_title_config.py
RENAMED
|
File without changes
|