wagtail 6.3.2__py3-none-any.whl → 6.3.4__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.
- wagtail/__init__.py +1 -1
- wagtail/admin/static/wagtailadmin/css/core.css +1 -1
- wagtail/admin/static/wagtailadmin/css/panels/streamfield.css +1 -1
- wagtail/admin/templates/wagtailadmin/home/upgrade_notification.html +1 -0
- wagtail/admin/tests/test_upgrade_notification.py +3 -0
- wagtail/admin/userbar.py +1 -0
- wagtail/blocks/migrations/operations.py +10 -10
- wagtail/blocks/stream_block.py +1 -1
- wagtail/contrib/forms/tests/test_models.py +7 -5
- wagtail/migrations/0087_alter_grouppagepermission_unique_together_and_more.py +16 -8
- wagtail/search/backends/base.py +1 -6
- wagtail/search/backends/database/mysql/mysql.py +6 -2
- wagtail/search/tests/test_mysql_backend.py +75 -0
- wagtail/test/snippets/apps.py +10 -0
- wagtail/test/streamfield_migrations/testutils.py +4 -4
- wagtail/tests/streamfield_migrations/test_migration_names.py +6 -6
- wagtail/tests/streamfield_migrations/test_migrations.py +46 -1
- wagtail/tests/test_streamfield.py +18 -0
- wagtail/users/permission_order.py +16 -2
- wagtail/users/templatetags/wagtailusers_tags.py +3 -2
- wagtail-6.3.4.dist-info/METADATA +89 -0
- {wagtail-6.3.2.dist-info → wagtail-6.3.4.dist-info}/RECORD +26 -26
- {wagtail-6.3.2.dist-info → wagtail-6.3.4.dist-info}/WHEEL +1 -1
- wagtail-6.3.2.dist-info/METADATA +0 -77
- {wagtail-6.3.2.dist-info → wagtail-6.3.4.dist-info}/entry_points.txt +0 -0
- {wagtail-6.3.2.dist-info → wagtail-6.3.4.dist-info/licenses}/LICENSE +0 -0
- {wagtail-6.3.2.dist-info → wagtail-6.3.4.dist-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
.c-sf-add-button{align-items:center;-webkit-appearance:none;appearance:none;background-color:var(--w-color-surface-page);color:var(--w-color-text-button-outline-default);cursor:pointer;display:grid;height:1.5rem;justify-content:center;margin-inline-start:calc(-1px + -.25rem);padding:0;width:1.5rem}.c-sf-add-button .icon{border:1px solid;border-radius:100%;height:1rem;padding:.125rem;transition:transform .3s ease;width:1rem}.c-sf-add-button[aria-expanded=true] .icon{transform:rotate(45deg)}.c-sf-add-button:focus-visible .icon,.c-sf-add-button:hover .icon{background-color:var(--w-color-text-button-outline-hover);color:var(--w-color-surface-page)}.c-sf-add-button[disabled]{opacity:.2}@media (forced-colors:active){.c-sf-add-button[disabled]{color:GrayText}}[aria-expanded=true]+.w-panel__heading .c-sf-block__title{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}[aria-expanded=false]+.w-panel__heading .c-sf-block__title:not(:empty)+.c-sf-block__type{display:none}.c-sf-help .help{margin-bottom:
|
|
1
|
+
.c-sf-add-button{align-items:center;-webkit-appearance:none;appearance:none;background-color:var(--w-color-surface-page);color:var(--w-color-text-button-outline-default);cursor:pointer;display:grid;height:1.5rem;justify-content:center;margin-inline-start:calc(-1px + -.25rem);padding:0;width:1.5rem}.c-sf-add-button .icon{border:1px solid;border-radius:100%;height:1rem;padding:.125rem;transition:transform .3s ease;width:1rem}.c-sf-add-button[aria-expanded=true] .icon{transform:rotate(45deg)}.c-sf-add-button:focus-visible .icon,.c-sf-add-button:hover .icon{background-color:var(--w-color-text-button-outline-hover);color:var(--w-color-surface-page)}.c-sf-add-button[disabled]{opacity:.2}@media (forced-colors:active){.c-sf-add-button[disabled]{color:GrayText}}[aria-expanded=true]+.w-panel__heading .c-sf-block__title{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}[aria-expanded=false]+.w-panel__heading .c-sf-block__title:not(:empty)+.c-sf-block__type{display:none}.c-sf-help .help{margin-bottom:1rem;margin-top:0}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
data-action="w-dismissible#toggle"
|
|
26
26
|
{% if dismissible_value %}data-w-dismissible-value-param="{{ dismissible_value }}"{% endif %}
|
|
27
27
|
data-w-upgrade-target="dismiss"
|
|
28
|
+
aria-label="{% trans 'Close' %}"
|
|
28
29
|
class="w-ml-auto w-flex w-items-center w-justify-center w-bg-transparent w-rounded-full w-p-0 w-w-8 w-h-8
|
|
29
30
|
w-text-current
|
|
30
31
|
w-border
|
|
@@ -78,6 +78,7 @@ class TestUpgradeNotificationPanel(WagtailTestUtils, TestCase):
|
|
|
78
78
|
)
|
|
79
79
|
toggle = soup.select_one("[data-action='w-dismissible#toggle']")
|
|
80
80
|
self.assertIsNotNone(toggle)
|
|
81
|
+
self.assertEqual(toggle.get("aria-label"), "Close")
|
|
81
82
|
self.assertIsNone(toggle.get(self.ATTR_LAST_DISMISSED_VALUE))
|
|
82
83
|
|
|
83
84
|
@override_settings(WAGTAIL_ENABLE_UPDATE_CHECK=False)
|
|
@@ -115,6 +116,7 @@ class TestUpgradeNotificationPanel(WagtailTestUtils, TestCase):
|
|
|
115
116
|
)
|
|
116
117
|
toggle = soup.select_one("[data-action='w-dismissible#toggle']")
|
|
117
118
|
self.assertIsNotNone(toggle)
|
|
119
|
+
self.assertEqual(toggle.get("aria-label"), "Close")
|
|
118
120
|
self.assertIsNone(toggle.get(self.ATTR_LAST_DISMISSED_VALUE))
|
|
119
121
|
|
|
120
122
|
def test_render_html_dismissed_version(self):
|
|
@@ -140,6 +142,7 @@ class TestUpgradeNotificationPanel(WagtailTestUtils, TestCase):
|
|
|
140
142
|
)
|
|
141
143
|
toggle = soup.select_one("[data-action='w-dismissible#toggle']")
|
|
142
144
|
self.assertIsNotNone(toggle)
|
|
145
|
+
self.assertEqual(toggle.get("aria-label"), "Close")
|
|
143
146
|
self.assertEqual(
|
|
144
147
|
toggle.get(self.ATTR_LAST_DISMISSED_VALUE),
|
|
145
148
|
"6.2.2",
|
wagtail/admin/userbar.py
CHANGED
|
@@ -153,29 +153,29 @@ class StreamChildrenToListBlockOperation(BaseBlockOperation):
|
|
|
153
153
|
super().__init__()
|
|
154
154
|
self.block_name = block_name
|
|
155
155
|
self.list_block_name = list_block_name
|
|
156
|
-
self.temp_blocks = []
|
|
157
156
|
|
|
158
157
|
def apply(self, block_value):
|
|
158
|
+
candidate_blocks = []
|
|
159
159
|
mapped_block_value = []
|
|
160
160
|
for child_block in block_value:
|
|
161
161
|
if child_block["type"] == self.block_name:
|
|
162
|
-
|
|
162
|
+
candidate_blocks.append(child_block)
|
|
163
163
|
else:
|
|
164
164
|
mapped_block_value.append(child_block)
|
|
165
165
|
|
|
166
|
-
self.map_temp_blocks_to_list_items()
|
|
166
|
+
list_items = self.map_temp_blocks_to_list_items(candidate_blocks)
|
|
167
167
|
|
|
168
|
-
if
|
|
169
|
-
new_list_block = {"type": self.list_block_name, "value":
|
|
168
|
+
if list_items:
|
|
169
|
+
new_list_block = {"type": self.list_block_name, "value": list_items}
|
|
170
170
|
mapped_block_value.append(new_list_block)
|
|
171
171
|
|
|
172
172
|
return mapped_block_value
|
|
173
173
|
|
|
174
|
-
def map_temp_blocks_to_list_items(self):
|
|
175
|
-
|
|
176
|
-
for block in
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
def map_temp_blocks_to_list_items(self, blocks):
|
|
175
|
+
list_items = []
|
|
176
|
+
for block in blocks:
|
|
177
|
+
list_items.append({**block, "type": "item"})
|
|
178
|
+
return list_items
|
|
179
179
|
|
|
180
180
|
@property
|
|
181
181
|
def operation_name_fragment(self):
|
wagtail/blocks/stream_block.py
CHANGED
|
@@ -710,7 +710,7 @@ class StreamValue(MutableSequence):
|
|
|
710
710
|
raw_values = OrderedDict(
|
|
711
711
|
(i, raw_item["value"])
|
|
712
712
|
for i, raw_item in enumerate(self._raw_data)
|
|
713
|
-
if
|
|
713
|
+
if self._bound_blocks[i] is None and raw_item["type"] == type_name
|
|
714
714
|
)
|
|
715
715
|
# pass the raw block values to bulk_to_python as a list
|
|
716
716
|
converted_values = child_block.bulk_to_python(raw_values.values())
|
|
@@ -603,11 +603,13 @@ class TestFormPageWithCustomFormBuilder(WagtailTestUtils, TestCase):
|
|
|
603
603
|
html=True,
|
|
604
604
|
)
|
|
605
605
|
# check ip address field has rendered
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
)
|
|
606
|
+
# (not comparing HTML directly because https://docs.djangoproject.com/en/5.1/releases/5.1.5/
|
|
607
|
+
# added a maxlength attribute)
|
|
608
|
+
soup = self.get_soup(response.content)
|
|
609
|
+
input = soup.find("input", {"name": "device_ip_address"})
|
|
610
|
+
self.assertEqual(input["type"], "text")
|
|
611
|
+
self.assertEqual(input["required"], "")
|
|
612
|
+
self.assertEqual(input["id"], "id_device_ip_address")
|
|
611
613
|
|
|
612
614
|
def test_post_invalid_form(self):
|
|
613
615
|
response = self.client.post(
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
# Generated by Django 4.2.1 on 2023-06-21 11:44
|
|
2
2
|
|
|
3
|
+
from django import VERSION as DJANGO_VERSION
|
|
3
4
|
from django.db import migrations, models
|
|
4
5
|
|
|
5
6
|
|
|
7
|
+
check_constraint_condition = models.Q(
|
|
8
|
+
("permission__isnull", False),
|
|
9
|
+
("permission_type__isnull", False),
|
|
10
|
+
_connector="OR",
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
check_constraint_kwargs = {"name": "permission_or_permission_type_not_null"}
|
|
14
|
+
|
|
15
|
+
if DJANGO_VERSION >= (5, 1):
|
|
16
|
+
check_constraint_kwargs["condition"] = check_constraint_condition
|
|
17
|
+
else:
|
|
18
|
+
check_constraint_kwargs["check"] = check_constraint_condition
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
class Migration(migrations.Migration):
|
|
7
22
|
|
|
8
23
|
dependencies = [
|
|
@@ -16,14 +31,7 @@ class Migration(migrations.Migration):
|
|
|
16
31
|
),
|
|
17
32
|
migrations.AddConstraint(
|
|
18
33
|
model_name="grouppagepermission",
|
|
19
|
-
constraint=models.CheckConstraint(
|
|
20
|
-
check=models.Q(
|
|
21
|
-
("permission__isnull", False),
|
|
22
|
-
("permission_type__isnull", False),
|
|
23
|
-
_connector="OR",
|
|
24
|
-
),
|
|
25
|
-
name="permission_or_permission_type_not_null",
|
|
26
|
-
),
|
|
34
|
+
constraint=models.CheckConstraint(**check_constraint_kwargs),
|
|
27
35
|
),
|
|
28
36
|
migrations.AddConstraint(
|
|
29
37
|
model_name="grouppagepermission",
|
wagtail/search/backends/base.py
CHANGED
|
@@ -5,7 +5,7 @@ from django.db.models.functions.datetime import Extract as ExtractDate
|
|
|
5
5
|
from django.db.models.functions.datetime import ExtractYear
|
|
6
6
|
from django.db.models.lookups import Lookup
|
|
7
7
|
from django.db.models.query import QuerySet
|
|
8
|
-
from django.db.models.sql.where import
|
|
8
|
+
from django.db.models.sql.where import WhereNode
|
|
9
9
|
|
|
10
10
|
from wagtail.search.index import class_is_indexed, get_indexed_models
|
|
11
11
|
from wagtail.search.query import MATCH_ALL, PlainText
|
|
@@ -179,11 +179,6 @@ class BaseSearchQueryCompiler:
|
|
|
179
179
|
field_attname, lookup, value, check_only=check_only
|
|
180
180
|
)
|
|
181
181
|
|
|
182
|
-
elif isinstance(where_node, SubqueryConstraint):
|
|
183
|
-
raise FilterError(
|
|
184
|
-
"Could not apply filter on search results: Subqueries are not allowed."
|
|
185
|
-
)
|
|
186
|
-
|
|
187
182
|
elif isinstance(where_node, WhereNode):
|
|
188
183
|
# Get child filters
|
|
189
184
|
connector = where_node.connector
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import re
|
|
1
2
|
import warnings
|
|
2
3
|
from collections import OrderedDict
|
|
3
4
|
|
|
@@ -336,9 +337,12 @@ class MySQLSearchQueryCompiler(BaseSearchQueryCompiler):
|
|
|
336
337
|
|
|
337
338
|
def build_search_query_content(self, query, invert=False):
|
|
338
339
|
if isinstance(query, PlainText):
|
|
339
|
-
|
|
340
|
+
# For Boolean full text search queries in MySQL,
|
|
341
|
+
# non-alphanumeric characters act as separators
|
|
342
|
+
terms = [term for term in re.split(r"\W+", query.query_string) if term]
|
|
343
|
+
|
|
340
344
|
if not terms:
|
|
341
|
-
return
|
|
345
|
+
return SearchQuery("")
|
|
342
346
|
|
|
343
347
|
last_term = terms.pop()
|
|
344
348
|
|
|
@@ -68,6 +68,81 @@ class TestMySQLSearchBackend(BackendTests, TransactionTestCase):
|
|
|
68
68
|
all_other_titles | {"JavaScript: The Definitive Guide"},
|
|
69
69
|
)
|
|
70
70
|
|
|
71
|
+
def test_empty_search(self):
|
|
72
|
+
results = self.backend.search("", models.Book.objects.all())
|
|
73
|
+
self.assertSetEqual(
|
|
74
|
+
{r.title for r in results},
|
|
75
|
+
set(),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
results = self.backend.search(" ", models.Book.objects.all())
|
|
79
|
+
self.assertSetEqual(
|
|
80
|
+
{r.title for r in results},
|
|
81
|
+
set(),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
results = self.backend.search("*", models.Book.objects.all())
|
|
85
|
+
self.assertSetEqual(
|
|
86
|
+
{r.title for r in results},
|
|
87
|
+
set(),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def test_empty_autocomplete(self):
|
|
91
|
+
results = self.backend.autocomplete("", models.Book.objects.all())
|
|
92
|
+
self.assertSetEqual(
|
|
93
|
+
{r.title for r in results},
|
|
94
|
+
set(),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
results = self.backend.autocomplete(" ", models.Book.objects.all())
|
|
98
|
+
self.assertSetEqual(
|
|
99
|
+
{r.title for r in results},
|
|
100
|
+
set(),
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
results = self.backend.autocomplete("*", models.Book.objects.all())
|
|
104
|
+
self.assertSetEqual(
|
|
105
|
+
{r.title for r in results},
|
|
106
|
+
set(),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
def test_symbols_in_search_term(self):
|
|
110
|
+
# symbols as their own tokens should be ignored
|
|
111
|
+
results = self.backend.search("javascript @ parts", models.Book.objects.all())
|
|
112
|
+
self.assertSetEqual(
|
|
113
|
+
{r.title for r in results},
|
|
114
|
+
{"JavaScript: The good parts"},
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
results = self.backend.search("javascript parts @", models.Book.objects.all())
|
|
118
|
+
self.assertSetEqual(
|
|
119
|
+
{r.title for r in results},
|
|
120
|
+
{"JavaScript: The good parts"},
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
results = self.backend.search("@ javascript parts", models.Book.objects.all())
|
|
124
|
+
self.assertSetEqual(
|
|
125
|
+
{r.title for r in results},
|
|
126
|
+
{"JavaScript: The good parts"},
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# tokens containing both symbols and alphanumerics should not be discarded
|
|
130
|
+
# or treated as equivalent to the same token without symbols
|
|
131
|
+
results = self.backend.search("java@script parts", models.Book.objects.all())
|
|
132
|
+
self.assertSetEqual(
|
|
133
|
+
{r.title for r in results},
|
|
134
|
+
set(),
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
def test_autocomplete_with_symbols(self):
|
|
138
|
+
# the * is not part of the autocomplete mechanism, but if someone includes it
|
|
139
|
+
# we want it to be gracefully ignored
|
|
140
|
+
results = self.backend.autocomplete("parts javasc*", models.Book.objects.all())
|
|
141
|
+
self.assertSetEqual(
|
|
142
|
+
{r.title for r in results},
|
|
143
|
+
{"JavaScript: The good parts"},
|
|
144
|
+
)
|
|
145
|
+
|
|
71
146
|
@skip(
|
|
72
147
|
"The MySQL backend doesn't support choosing individual fields for the search, only (body, title) or (autocomplete) fields may be searched."
|
|
73
148
|
)
|
wagtail/test/snippets/apps.py
CHANGED
|
@@ -7,3 +7,13 @@ class WagtailSnippetsTestsAppConfig(AppConfig):
|
|
|
7
7
|
name = "wagtail.test.snippets"
|
|
8
8
|
label = "snippetstests"
|
|
9
9
|
verbose_name = _("Wagtail snippets tests")
|
|
10
|
+
|
|
11
|
+
def ready(self):
|
|
12
|
+
# Test registration of permission order within the group permissions view,
|
|
13
|
+
# as per https://docs.wagtail.org/en/stable/extending/customizing_group_views.html#customizing-the-group-editor-permissions-ordering
|
|
14
|
+
# Invoking `register` from `ready` confirms that it does not perform any database queries -
|
|
15
|
+
# if it did, it would fail (on a standard test run without --keepdb at least) because the
|
|
16
|
+
# test database hasn't been migrated yet.
|
|
17
|
+
from wagtail.users.permission_order import register
|
|
18
|
+
|
|
19
|
+
register("snippetstests.fancysnippet", order=999)
|
|
@@ -10,7 +10,7 @@ class MigrationTestMixin:
|
|
|
10
10
|
default_operation_and_block_path = []
|
|
11
11
|
app_name = None
|
|
12
12
|
|
|
13
|
-
def init_migration(self, revisions_from=None,
|
|
13
|
+
def init_migration(self, revisions_from=None, operations_and_block_paths=None):
|
|
14
14
|
migration = Migration(
|
|
15
15
|
"test_migration", "wagtail_streamfield_migration_toolkit_test"
|
|
16
16
|
)
|
|
@@ -18,7 +18,7 @@ class MigrationTestMixin:
|
|
|
18
18
|
app_name=self.app_name,
|
|
19
19
|
model_name=self.model.__name__,
|
|
20
20
|
field_name="content",
|
|
21
|
-
operations_and_block_paths=
|
|
21
|
+
operations_and_block_paths=operations_and_block_paths
|
|
22
22
|
or self.default_operation_and_block_path,
|
|
23
23
|
revisions_from=revisions_from,
|
|
24
24
|
)
|
|
@@ -29,11 +29,11 @@ class MigrationTestMixin:
|
|
|
29
29
|
def apply_migration(
|
|
30
30
|
self,
|
|
31
31
|
revisions_from=None,
|
|
32
|
-
|
|
32
|
+
operations_and_block_paths=None,
|
|
33
33
|
):
|
|
34
34
|
migration = self.init_migration(
|
|
35
35
|
revisions_from=revisions_from,
|
|
36
|
-
|
|
36
|
+
operations_and_block_paths=operations_and_block_paths,
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
loader = MigrationLoader(connection=connection)
|
|
@@ -13,35 +13,35 @@ class MigrationNameTest(TestCase, MigrationTestMixin):
|
|
|
13
13
|
app_name = "wagtail_streamfield_migration_toolkit_test"
|
|
14
14
|
|
|
15
15
|
def test_rename(self):
|
|
16
|
-
|
|
16
|
+
operations_and_block_paths = [
|
|
17
17
|
(
|
|
18
18
|
RenameStreamChildrenOperation(old_name="char1", new_name="renamed1"),
|
|
19
19
|
"",
|
|
20
20
|
)
|
|
21
21
|
]
|
|
22
22
|
migration = self.init_migration(
|
|
23
|
-
|
|
23
|
+
operations_and_block_paths=operations_and_block_paths
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
suggested_name = migration.suggest_name()
|
|
27
27
|
self.assertEqual(suggested_name, "rename_char1_to_renamed1")
|
|
28
28
|
|
|
29
29
|
def test_remove(self):
|
|
30
|
-
|
|
30
|
+
operations_and_block_paths = [
|
|
31
31
|
(
|
|
32
32
|
RemoveStreamChildrenOperation(name="char1"),
|
|
33
33
|
"",
|
|
34
34
|
)
|
|
35
35
|
]
|
|
36
36
|
migration = self.init_migration(
|
|
37
|
-
|
|
37
|
+
operations_and_block_paths=operations_and_block_paths
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
suggested_name = migration.suggest_name()
|
|
41
41
|
self.assertEqual(suggested_name, "remove_char1")
|
|
42
42
|
|
|
43
43
|
def test_multiple(self):
|
|
44
|
-
|
|
44
|
+
operations_and_block_paths = [
|
|
45
45
|
(
|
|
46
46
|
RenameStreamChildrenOperation(old_name="char1", new_name="renamed1"),
|
|
47
47
|
"",
|
|
@@ -52,7 +52,7 @@ class MigrationNameTest(TestCase, MigrationTestMixin):
|
|
|
52
52
|
),
|
|
53
53
|
]
|
|
54
54
|
migration = self.init_migration(
|
|
55
|
-
|
|
55
|
+
operations_and_block_paths=operations_and_block_paths
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
suggested_name = migration.suggest_name()
|
|
@@ -7,7 +7,10 @@ from django.db.models.functions import Cast
|
|
|
7
7
|
from django.test import TestCase
|
|
8
8
|
from django.utils import timezone
|
|
9
9
|
|
|
10
|
-
from wagtail.blocks.migrations.operations import
|
|
10
|
+
from wagtail.blocks.migrations.operations import (
|
|
11
|
+
RenameStreamChildrenOperation,
|
|
12
|
+
StreamChildrenToListBlockOperation,
|
|
13
|
+
)
|
|
11
14
|
from wagtail.test.streamfield_migrations import factories, models
|
|
12
15
|
from wagtail.test.streamfield_migrations.testutils import MigrationTestMixin
|
|
13
16
|
|
|
@@ -250,3 +253,45 @@ class TestNullStreamField(BaseMigrationTest):
|
|
|
250
253
|
self.assert_null_content()
|
|
251
254
|
self.apply_migration()
|
|
252
255
|
self.assert_null_content()
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class StreamChildrenToListBlockOperationTestCase(BaseMigrationTest):
|
|
259
|
+
model = models.SamplePage
|
|
260
|
+
factory = factories.SamplePageFactory
|
|
261
|
+
has_revisions = True
|
|
262
|
+
app_name = "streamfield_migration_tests"
|
|
263
|
+
|
|
264
|
+
def _get_test_instances(self):
|
|
265
|
+
return self.factory.create_batch(
|
|
266
|
+
size=3,
|
|
267
|
+
# Each content stream field has a single char block instance.
|
|
268
|
+
content__0__char1__value="Char Block 1",
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
def test_state_not_shared_across_instances(self):
|
|
272
|
+
"""
|
|
273
|
+
StreamChildrenToListBlockOperation doesn't share state across model instances.
|
|
274
|
+
|
|
275
|
+
As a single operation instance is used to transform the data of multiple model
|
|
276
|
+
instances, we should not store model instance state on the operation instance.
|
|
277
|
+
See https://github.com/wagtail/wagtail/issues/12391.
|
|
278
|
+
"""
|
|
279
|
+
|
|
280
|
+
self.apply_migration(
|
|
281
|
+
operations_and_block_paths=[
|
|
282
|
+
(
|
|
283
|
+
StreamChildrenToListBlockOperation(
|
|
284
|
+
block_name="char1", list_block_name="list1"
|
|
285
|
+
),
|
|
286
|
+
"",
|
|
287
|
+
)
|
|
288
|
+
]
|
|
289
|
+
)
|
|
290
|
+
for instance in self.model.objects.all().annotate(
|
|
291
|
+
raw_content=Cast(F("content"), JSONField())
|
|
292
|
+
):
|
|
293
|
+
new_block = instance.raw_content[0]
|
|
294
|
+
self.assertEqual(new_block["type"], "list1")
|
|
295
|
+
self.assertEqual(len(new_block["value"]), 1)
|
|
296
|
+
self.assertEqual(new_block["value"][0]["type"], "item")
|
|
297
|
+
self.assertEqual(new_block["value"][0]["value"], "Char Block 1")
|
|
@@ -237,6 +237,24 @@ class TestStreamValueAccess(TestCase):
|
|
|
237
237
|
self.assertEqual(fetched_body[1].block_type, "text")
|
|
238
238
|
self.assertEqual(fetched_body[1].value, "bar")
|
|
239
239
|
|
|
240
|
+
def test_can_append_on_queried_instance(self):
|
|
241
|
+
# The test is analog to test_can_append(), but instead of working with the
|
|
242
|
+
# in-memory version from JSONStreamModel.objects.create(), we query a fresh
|
|
243
|
+
# instance from the db.
|
|
244
|
+
# It tests adding data to child blocks that
|
|
245
|
+
# have not yet been lazy loaded. This would previously crash.
|
|
246
|
+
self.json_body = JSONStreamModel.objects.get(pk=self.json_body.pk)
|
|
247
|
+
self.json_body.body.append(("text", "bar"))
|
|
248
|
+
self.json_body.save()
|
|
249
|
+
|
|
250
|
+
fetched_body = JSONStreamModel.objects.get(id=self.json_body.id).body
|
|
251
|
+
self.assertIsInstance(fetched_body, StreamValue)
|
|
252
|
+
self.assertEqual(len(fetched_body), 2)
|
|
253
|
+
self.assertEqual(fetched_body[0].block_type, "text")
|
|
254
|
+
self.assertEqual(fetched_body[0].value, "foo")
|
|
255
|
+
self.assertEqual(fetched_body[1].block_type, "text")
|
|
256
|
+
self.assertEqual(fetched_body[1].value, "bar")
|
|
257
|
+
|
|
240
258
|
def test_complex_assignment(self):
|
|
241
259
|
page = StreamPage(title="Test page", body=[])
|
|
242
260
|
page.body = [
|
|
@@ -2,6 +2,7 @@ from django.contrib.contenttypes.models import ContentType
|
|
|
2
2
|
|
|
3
3
|
from wagtail.coreutils import resolve_model_string
|
|
4
4
|
|
|
5
|
+
content_types_to_register = []
|
|
5
6
|
CONTENT_TYPE_ORDER = {}
|
|
6
7
|
|
|
7
8
|
|
|
@@ -13,5 +14,18 @@ def register(model, **kwargs):
|
|
|
13
14
|
"""
|
|
14
15
|
order = kwargs.pop("order", None)
|
|
15
16
|
if order is not None:
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
# We typically call this at application startup, when the database may not be ready,
|
|
18
|
+
# and so we can't look up the content type yet. Instead we will queue up the
|
|
19
|
+
# (model, order) pair to be processed when the lookup is requested.
|
|
20
|
+
content_types_to_register.append((model, order))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_content_type_order_lookup():
|
|
24
|
+
if content_types_to_register:
|
|
25
|
+
for model, order in content_types_to_register:
|
|
26
|
+
content_type = ContentType.objects.get_for_model(
|
|
27
|
+
resolve_model_string(model)
|
|
28
|
+
)
|
|
29
|
+
CONTENT_TYPE_ORDER[content_type.id] = order
|
|
30
|
+
content_types_to_register.clear()
|
|
31
|
+
return CONTENT_TYPE_ORDER
|
|
@@ -11,7 +11,7 @@ from django.utils.translation import gettext_noop
|
|
|
11
11
|
from wagtail import hooks
|
|
12
12
|
from wagtail.admin.models import Admin
|
|
13
13
|
from wagtail.coreutils import accepts_kwarg
|
|
14
|
-
from wagtail.users.permission_order import
|
|
14
|
+
from wagtail.users.permission_order import get_content_type_order_lookup
|
|
15
15
|
from wagtail.utils.deprecation import RemovedInWagtail70Warning
|
|
16
16
|
|
|
17
17
|
register = template.Library()
|
|
@@ -96,9 +96,10 @@ def format_permissions(permission_bound_field):
|
|
|
96
96
|
# get a distinct and ordered list of the content types that these permissions relate to.
|
|
97
97
|
# relies on Permission model default ordering, dict.fromkeys() retaining that order
|
|
98
98
|
# from the queryset, and the stability of sorted().
|
|
99
|
+
content_type_order = get_content_type_order_lookup()
|
|
99
100
|
content_type_ids = sorted(
|
|
100
101
|
dict.fromkeys(permissions.values_list("content_type_id", flat=True)),
|
|
101
|
-
key=lambda ct:
|
|
102
|
+
key=lambda ct: content_type_order.get(ct, float("inf")),
|
|
102
103
|
)
|
|
103
104
|
|
|
104
105
|
# iterate over permission_bound_field to build a lookup of individual renderable
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wagtail
|
|
3
|
+
Version: 6.3.4
|
|
4
|
+
Summary: A Django content management system.
|
|
5
|
+
Home-page: https://wagtail.org/
|
|
6
|
+
Author: Wagtail core team + contributors
|
|
7
|
+
Author-email: hello@wagtail.org
|
|
8
|
+
License: BSD
|
|
9
|
+
Project-URL: Changelog, https://github.com/wagtail/wagtail/blob/main/CHANGELOG.txt
|
|
10
|
+
Project-URL: Documentation, https://docs.wagtail.org
|
|
11
|
+
Project-URL: Source, https://github.com/wagtail/wagtail
|
|
12
|
+
Project-URL: Tracker, https://github.com/wagtail/wagtail/issues
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Environment :: Web Environment
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Framework :: Django
|
|
26
|
+
Classifier: Framework :: Django :: 4.2
|
|
27
|
+
Classifier: Framework :: Django :: 5.0
|
|
28
|
+
Classifier: Framework :: Django :: 5.1
|
|
29
|
+
Classifier: Framework :: Wagtail
|
|
30
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Site Management
|
|
31
|
+
Requires-Python: >=3.9
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: Django<6.0,>=4.2
|
|
34
|
+
Requires-Dist: django-modelcluster<7.0,>=6.2.1
|
|
35
|
+
Requires-Dist: django-permissionedforms<1.0,>=0.1
|
|
36
|
+
Requires-Dist: django-taggit<6.2,>=5.0
|
|
37
|
+
Requires-Dist: django-treebeard<5.0,>=4.5.1
|
|
38
|
+
Requires-Dist: djangorestframework<4.0,>=3.15.1
|
|
39
|
+
Requires-Dist: django-filter>=23.3
|
|
40
|
+
Requires-Dist: draftjs_exporter<6.0,>=2.1.5
|
|
41
|
+
Requires-Dist: Pillow<12.0.0,>=9.1.0
|
|
42
|
+
Requires-Dist: beautifulsoup4<4.13,>=4.8
|
|
43
|
+
Requires-Dist: Willow[heif]<2,>=1.8.0
|
|
44
|
+
Requires-Dist: requests<3.0,>=2.11.1
|
|
45
|
+
Requires-Dist: l18n>=2018.5
|
|
46
|
+
Requires-Dist: openpyxl<4.0,>=3.0.10
|
|
47
|
+
Requires-Dist: anyascii>=0.1.5
|
|
48
|
+
Requires-Dist: telepath<1,>=0.3.1
|
|
49
|
+
Requires-Dist: laces<0.2,>=0.1
|
|
50
|
+
Provides-Extra: testing
|
|
51
|
+
Requires-Dist: python-dateutil>=2.7; extra == "testing"
|
|
52
|
+
Requires-Dist: Jinja2<3.2,>=3.0; extra == "testing"
|
|
53
|
+
Requires-Dist: boto3<2,>=1.28; extra == "testing"
|
|
54
|
+
Requires-Dist: freezegun>=0.3.8; extra == "testing"
|
|
55
|
+
Requires-Dist: azure-mgmt-cdn<13.0,>=12.0; extra == "testing"
|
|
56
|
+
Requires-Dist: azure-mgmt-frontdoor<1.1,>=1.0; extra == "testing"
|
|
57
|
+
Requires-Dist: django-pattern-library>=0.7; extra == "testing"
|
|
58
|
+
Requires-Dist: coverage>=3.7.0; extra == "testing"
|
|
59
|
+
Requires-Dist: doc8==0.8.1; extra == "testing"
|
|
60
|
+
Requires-Dist: ruff==0.1.5; extra == "testing"
|
|
61
|
+
Requires-Dist: semgrep==1.40.0; extra == "testing"
|
|
62
|
+
Requires-Dist: curlylint==0.13.1; extra == "testing"
|
|
63
|
+
Requires-Dist: djhtml==3.0.6; extra == "testing"
|
|
64
|
+
Requires-Dist: polib<2.0,>=1.1; extra == "testing"
|
|
65
|
+
Requires-Dist: factory-boy>=3.2; extra == "testing"
|
|
66
|
+
Requires-Dist: tblib<3.0,>=2.0; extra == "testing"
|
|
67
|
+
Provides-Extra: docs
|
|
68
|
+
Requires-Dist: pyenchant<4,>=3.1.1; extra == "docs"
|
|
69
|
+
Requires-Dist: sphinxcontrib-spelling<8,>=7; extra == "docs"
|
|
70
|
+
Requires-Dist: Sphinx>=7.3; extra == "docs"
|
|
71
|
+
Requires-Dist: sphinx-autobuild>=0.6.0; extra == "docs"
|
|
72
|
+
Requires-Dist: sphinx-wagtail-theme==6.4.0; extra == "docs"
|
|
73
|
+
Requires-Dist: myst_parser==2.0.0; extra == "docs"
|
|
74
|
+
Dynamic: author
|
|
75
|
+
Dynamic: author-email
|
|
76
|
+
Dynamic: classifier
|
|
77
|
+
Dynamic: description
|
|
78
|
+
Dynamic: home-page
|
|
79
|
+
Dynamic: license
|
|
80
|
+
Dynamic: license-file
|
|
81
|
+
Dynamic: project-url
|
|
82
|
+
Dynamic: provides-extra
|
|
83
|
+
Dynamic: requires-dist
|
|
84
|
+
Dynamic: requires-python
|
|
85
|
+
Dynamic: summary
|
|
86
|
+
|
|
87
|
+
Wagtail is an open source content management system built on Django, with a strong community and commercial support. It’s focused on user experience, and offers precise control for designers and developers.
|
|
88
|
+
|
|
89
|
+
For more details, see https://wagtail.org, https://docs.wagtail.org and https://github.com/wagtail/wagtail/.
|