Skip to content

Commit

Permalink
Merge branch 'main' into feature/10418-block-picker-design
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed Jul 14, 2023
2 parents 5f5c844 + 9881ec1 commit 1a42244
Show file tree
Hide file tree
Showing 290 changed files with 520 additions and 655 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
paths:
- .venv
- run: pipenv run ruff check .
- run: pipenv run black --target-version py37 --check --diff .
- run: pipenv run black --target-version py38 --check --diff .
- run: pipenv run semgrep --config .semgrep.yml --error .
- run: git ls-files '*.html' | xargs pipenv run djhtml --check
- run: pipenv run curlylint --parse-only wagtail
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ concurrency:
# - test runs with USE_EMAIL_USER_MODEL=yes and DISABLE_TIMEZONE=yes

# Current configuration:
# - django 3.2, python 3.7, postgres
# - django 3.2, python 3.8, postgres
# - django 3.2, python 3.8, mysql
# - django 4.1, python 3.9, sqlite
# - django 4.2, python 3.10, mysql
# - django 4.1, python 3.10, postgres, USE_EMAIL_USER_MODEL=yes
# - django 4.2, python 3.11, postgres, DISABLE_TIMEZONE=yes
# - django stable/4.2.x, python 3.10, postgres (allow failures)
# - django main, python 3.10, postgres (allow failures)
# - elasticsearch 5, django 3.2, python 3.7, sqlite
# - elasticsearch 6, django 3.2, python 3.7, postgres
# - elasticsearch 5, django 3.2, python 3.8, sqlite
# - elasticsearch 6, django 3.2, python 3.8, postgres
# - elasticsearch 7, django 4.1, python 3.8, postgres
# - elasticsearch 7, django 4.2, python 3.9, sqlite, USE_EMAIL_USER_MODEL=yes

Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
strategy:
matrix:
include:
- python: '3.7'
- python: '3.8'
django: 'Django>=3.2,<3.3'
experimental: false
- python: '3.11'
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
strategy:
matrix:
include:
- python: '3.7'
- python: '3.8'
django: 'Django>=3.2,<3.3'
steps:
- name: Configure sysctl limits
Expand Down Expand Up @@ -285,7 +285,7 @@ jobs:
strategy:
matrix:
include:
- python: '3.7'
- python: '3.8'
django: 'Django>=3.2,<3.3'

services:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
hooks:
- id: black
language_version: python3
args: ['--target-version', 'py37']
args: ['--target-version', 'py38']

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.272'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Changelog
* Change to always cache renditions (Jake Howard)
* Update link/document rich text tooltips for consistency with the inline toolbar (Albina Starykova)
* Increase the contrast between the rich text / StreamField block picker and the page in dark mode (Albina Starykova)
* Purge revisions of non-page models in `purge_revisions` command (Sage Abdullah)
* Fix: Prevent choosers from failing when initial value is an unrecognised ID, e.g. when moving a page from a location where `parent_page_types` would disallow it (Dan Braghis)
* Fix: Move comment notifications toggle to the comments side panel (Sage Abdullah)
* Fix: Remove comment button on InlinePanel fields (Sage Abdullah)
Expand Down Expand Up @@ -64,6 +65,7 @@ Changelog
* Docs: Switch the Getting started tutorial’s snippets example to be more understandable (Damilola Oladele)
* Docs: Update the deployment documentation page and remove outdated information (Jake Howard)
* Docs: Add more items to performance page regarding pre-fetching images and frontend caching (Jake Howard)
* Maintenance: Removed support for Python 3.7 (Dan Braghis)
* Maintenance: Switch to ruff for flake8 / isort code checking (Oliver Parker)
* Maintenance: Deprecate `insert_editor_css` in favour of `insert_global_admin_css` (Ester Beltrami)
* Maintenance: Optimise use of `specific` on Task and TaskState (Matt Westcott)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ _(If you are reading this on GitHub, the details here may not be indicative of t
Wagtail supports:

- Django 3.2.x, 4.1.x and 4.2.x
- Python 3.7, 3.8, 3.9, 3.10 and 3.11
- Python 3.8, 3.9, 3.10 and 3.11
- PostgreSQL, MySQL and SQLite (with JSON1) as database backends

[Previous versions of Wagtail](https://docs.wagtail.org/en/stable/releases/upgrading.html#compatible-django-python-versions) additionally supported Python 2.7 and earlier Django versions.
[Previous versions of Wagtail](https://docs.wagtail.org/en/stable/releases/upgrading.html#compatible-django-python-versions) additionally supported Python 2.7, 3.7 and earlier Django versions.

---

Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Wagtail documentation build configuration file, created by
# sphinx-quickstart on Tue Jan 14 17:38:55 2014.
Expand Down Expand Up @@ -85,7 +84,7 @@
# built documents.

# The short X.Y version.
version = "{}.{}".format(VERSION[0], VERSION[1])
version = f"{VERSION[0]}.{VERSION[1]}"
# The full version, including alpha/beta/rc tags.
release = __version__

Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you want to add Wagtail to an existing Django project instead, see [](integra

### Install dependencies

Wagtail supports Python 3.7, 3.8, 3.9, 3.10, and 3.11.
Wagtail supports Python 3.8, 3.9, 3.10, and 3.11.

To check if you have an appropriate version of Python 3, run the following command:

Expand All @@ -24,7 +24,7 @@ python3 --version
py --version
```

If none of the preceding commands return a version number, or return a version lower than 3.7, then [install Python 3](https://www.python.org/downloads/).
If none of the preceding commands return a version number, or return a version lower than 3.8, then [install Python 3](https://www.python.org/downloads/).

(virtual_environment_creation)=

Expand Down
12 changes: 9 additions & 3 deletions docs/reference/management_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ Options:
## purge_revisions

```sh
manage.py purge_revisions [--days=<number of days>]
manage.py purge_revisions [--days=<number of days>] [--pages] [--non-pages]
```

This command deletes old page revisions which are not in moderation, live, approved to go live, or the latest
revision for a page. If the `days` argument is supplied, only revisions older than the specified number of
This command deletes old revisions which are not in moderation, live, approved to go live, or the latest
revision. If the `days` argument is supplied, only revisions older than the specified number of
days will be deleted.

If the `pages` argument is supplied, only revisions of page models will be deleted. If the `non-pages` argument is supplied, only revisions of non-page models will be deleted. If both or neither arguments are supplied, revisions of all models will be deleted.

```{versionadded} 5.1
Support for deleting revisions of non-page models is added.
```

(purge_embeds)=

## purge_embeds
Expand Down
8 changes: 7 additions & 1 deletion docs/releases/5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ As part of tackling Wagtail’s technical debt and improving [CSP compatibility]
* Change to always cache renditions (Jake Howard)
* Update link/document rich text tooltips for consistency with the inline toolbar (Albina Starykova)
* Increase the contrast between the rich text / StreamField block picker and the page in dark mode (Albina Starykova)
* Purge revisions of non-page models in `purge_revisions` command (Sage Abdullah)

### Bug fixes

Expand Down Expand Up @@ -112,6 +113,7 @@ As part of tackling Wagtail’s technical debt and improving [CSP compatibility]

### Maintenance

* Removed support for Python 3.7 (Dan Braghis)
* Switch to ruff for flake8 / isort code checking (Oliver Parker)
* Deprecate `insert_editor_css` in favour of `insert_global_admin_css` (Ester Beltrami)
* Optimise use of `specific` on Task and TaskState (Matt Westcott)
Expand All @@ -138,6 +140,10 @@ As part of tackling Wagtail’s technical debt and improving [CSP compatibility]

## Upgrade considerations

### Removed support for Python 3.7

Python 3.7 is no longer supported as of this release; please upgrade to Python 3.8 or above before upgrading Wagtail.

### Pillow dependency update

Wagtail no longer supports Pillow versions below `9.1.0`.
Expand Down Expand Up @@ -316,7 +322,7 @@ Note: The `data-w-tag-options-value` is a JSON object serialised into string. Dj
### Image Renditions are now cached by default

Wagtail will try to use the cache called "renditions". If no such cache exists, it will fall back to using the default cache.
You can [configure the "renditions" cache](custom_image_renditions_cache) to use a different cache backend or to provide
You can [configure the "renditions" cache](custom_image_renditions_cache) to use a different cache backend or to provide
additional configuration parameters.

### Tooltips now rely on new data attributes
Expand Down
4 changes: 2 additions & 2 deletions docs/releases/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ New feature releases frequently add support for newer versions of Django and Pyt
The compatible versions of Django and Python for each Wagtail release are:

| Wagtail release | Compatible Django versions | Compatible Python versions |
| --------------- | -------------------------- | -------------------------- |
| 5.1 | 3.2, 4.1, 4.2 | 3.7, 3.8, 3.9, 3.10, 3.11 |
| --------------- | -------------------------- |----------------------------|
| 5.1 | 3.2, 4.1, 4.2 | 3.8, 3.9, 3.10, 3.11 |
| 5.0 | 3.2, 4.1, 4.2 | 3.7, 3.8, 3.9, 3.10, 3.11 |
| 4.2 | 3.2, 4.0, 4.1 | 3.7, 3.8, 3.9, 3.10, 3.11 |
| 4.1 LTS | 3.2, 4.0, 4.1 | 3.7, 3.8, 3.9, 3.10, 3.11 |
Expand Down
2 changes: 2 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ignore = ["D100","D101","D102","D103","D105","N806","E501"]
exclude = ["wagtail/project_template/*","node_modules","venv",".venv","migrations"]
line-length = 88

target-version = "py38" # minimum target version

# E: pycodestyle errors
# F: Pyflakes
# I: isort
Expand Down
5 changes: 2 additions & 3 deletions scripts/get-translator-credits.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import subprocess
from collections import defaultdict
from io import open

from babel import Locale

Expand All @@ -20,7 +19,7 @@
continue

# read author list from each file
with open(filename, "rt") as f:
with open(filename) as f:
has_found_translators_heading = False
for line in f:
line = line.strip()
Expand Down Expand Up @@ -60,7 +59,7 @@ def get_language_name(locale_string):
language_names.sort()

for (language_name, locale) in language_names:
print(("%s - %s" % (language_name, locale))) # noqa: T201
print(f"{language_name} - {locale}") # noqa: T201
print("-----") # noqa: T201
for author in sorted(authors_by_locale[locale]):
print(author.replace("@", ".")) # noqa: T201
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -118,7 +117,7 @@
"Framework :: Wagtail",
"Topic :: Internet :: WWW/HTTP :: Site Management",
],
python_requires=">=3.7",
python_requires=">=3.8",
install_requires=install_requires,
extras_require={"testing": testing_extras, "docs": documentation_extras},
entry_points="""
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
skipsdist = True
usedevelop = True

envlist = py{37,38,39,310,311}-dj{32,41,42,42stable,main}-{sqlite,postgres,mysql,mssql}-{elasticsearch7,elasticsearch6,elasticsearch5,noelasticsearch}-{customuser,emailuser}-{tz,notz},
envlist = py{38,39,310,311}-dj{32,41,42,42stable,main}-{sqlite,postgres,mysql,mssql}-{elasticsearch7,elasticsearch6,elasticsearch5,noelasticsearch}-{customuser,emailuser}-{tz,notz},

[testenv]
install_command = pip install -e ".[testing]" -U {opts} {packages}
Expand All @@ -13,7 +13,6 @@ commands =
noelasticsearch: coverage run runtests.py {posargs}

basepython =
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
Expand Down
4 changes: 1 addition & 3 deletions wagtail/admin/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,7 @@ def htmldiff(self):
block_rendered = comparison.htmlvalue(comparison.val_a)

classes = " ".join(classes)
comparisons_html.append(
'<div class="{0}">{1}</div>'.format(classes, block_rendered)
)
comparisons_html.append(f'<div class="{classes}">{block_rendered}</div>')

return mark_safe("\n".join(comparisons_html))

Expand Down
2 changes: 1 addition & 1 deletion wagtail/admin/forms/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def save(self, commit=True):
# will clear the now-updated field on self.instance too
try:
self._original_avatar.storage.delete(self._original_avatar.name)
except IOError:
except OSError:
# failure to delete the old avatar shouldn't prevent us from continuing
warnings.warn(
"Failed to delete old avatar file: %s" % self._original_avatar.name
Expand Down
2 changes: 1 addition & 1 deletion wagtail/admin/forms/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class CollectionMemberPermissionsForm(forms.Form):
)

GroupCollectionMemberPermissionFormSet = type(
str("GroupCollectionMemberPermissionFormSet"),
"GroupCollectionMemberPermissionFormSet",
(BaseGroupCollectionMemberPermissionFormSet,),
{
"permission_types": permission_types,
Expand Down
4 changes: 1 addition & 3 deletions wagtail/admin/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def __new__(cls, name, bases, attrs):
if "formfield_callback" not in attrs or attrs["formfield_callback"] is None:
attrs["formfield_callback"] = formfield_for_dbfield

new_class = super(WagtailAdminModelFormMetaclass, cls).__new__(
cls, name, bases, attrs
)
new_class = super().__new__(cls, name, bases, attrs)
return new_class

@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.db import migrations


Expand Down
4 changes: 2 additions & 2 deletions wagtail/admin/panels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def on_model_bound(self):
pass

def __repr__(self):
return "<%s with model=%s>" % (
return "<{} with model={}>".format(
self.__class__.__name__,
self.model,
)
Expand Down Expand Up @@ -317,7 +317,7 @@ def render_form_content(self):
return mark_safe(self.render_html() + self.render_missing_fields())

def __repr__(self):
return "<%s with model=%s instance=%s request=%s form=%s>" % (
return "<{} with model={} instance={} request={} form={}>".format(
self.__class__.__name__,
self.panel.model,
self.instance,
Expand Down
4 changes: 2 additions & 2 deletions wagtail/admin/panels/field_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def format_value_for_display(self, value):
return super().format_value_for_display(value)

def __repr__(self):
return "<%s '%s' with model=%s>" % (
return "<{} '{}' with model={}>".format(
self.__class__.__name__,
self.field_name,
self.model,
Expand Down Expand Up @@ -362,7 +362,7 @@ def get_comparison(self):
return []

def __repr__(self):
return "<%s '%s' with model=%s instance=%s request=%s form=%s>" % (
return "<{} '{}' with model={} instance={} request={} form={}>".format(
self.__class__.__name__,
self.field_name,
self.panel.model,
Expand Down
2 changes: 1 addition & 1 deletion wagtail/admin/panels/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def children(self):
instance=self.instance,
request=self.request,
form=self.form,
prefix=("%s-child-%s" % (self.prefix, identifier)),
prefix=(f"{self.prefix}-child-{identifier}"),
)
for child, identifier in zip(
self.panel.children, self.panel.child_identifiers
Expand Down
4 changes: 2 additions & 2 deletions wagtail/admin/rich_text/converters/editor_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def clean_tag_node(self, doc, tag):
if tag.name == "div":
tag.name = "p"

super(DbWhitelister, self).clean_tag_node(doc, tag)
super().clean_tag_node(doc, tag)


class EditorHTMLConverter:
Expand Down Expand Up @@ -176,6 +176,6 @@ def expand_db_attributes(attrs):
if parent_page:
attrs += 'data-parent-id="%d" ' % parent_page.id

return '<a %shref="%s">' % (attrs, escape(page.localized.specific.url))
return f'<a {attrs}href="{escape(page.localized.specific.url)}">'
except Page.DoesNotExist:
return "<a>"
2 changes: 1 addition & 1 deletion wagtail/admin/rich_text/converters/html_to_contentstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def handle_endtag(self, name):
if not self.open_elements:
return # avoid a pop from an empty list if we have an extra end tag
expected_name, element_handler = self.open_elements.pop()
assert name == expected_name, "Unmatched tags: expected %s, got %s" % (
assert name == expected_name, "Unmatched tags: expected {}, got {}".format(
expected_name,
name,
)
Expand Down
2 changes: 1 addition & 1 deletion wagtail/admin/templatetags/wagtailadmin_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ def component(context, obj, fallback_render_method=False):
if fallback_render_method and not has_render_html_method and hasattr(obj, "render"):
return obj.render()
elif not has_render_html_method:
raise ValueError("Cannot render %r as a component" % (obj,))
raise ValueError(f"Cannot render {obj!r} as a component")

return obj.render_html(context)

Expand Down
Loading

0 comments on commit 1a42244

Please sign in to comment.