Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop pre Wagtail 2.15 support #617

Merged
merged 5 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 6 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,13 @@ jobs:
strategy:
matrix:
python: ['3.7', '3.8', '3.9']
django: ['2.2']
wagtail: ['2.11', '2.12', '2.13']
django: ['3.2']
wagtail: ['2.15', '2.16', '3.0', '4.0']
include:
# Add test for Django 3.2 that is only suported on Wagtail 2.13+
- python: '3.9'
django: '3.2'
wagtail: '2.15'
- python: '3.9'
django: '3.2'
wagtail: '2.16'
- python: '3.9'
django: '3.2'
wagtail: '3.0'
- python: '3.9'
django: '3.2'
django: '4.1'
wagtail: '4.0'
experimental: false
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
Expand Down Expand Up @@ -77,31 +68,14 @@ jobs:
strategy:
matrix:
python: ['3.7', '3.8', '3.9']
django: ['2.2']
wagtail: ['2.11', '2.12', '2.13']
django: ['3.2']
wagtail: ['2.15', '2.16', '3.0']
experimental: [false]
include:
# Add test for Django 3.2 that is only suported on Wagtail 2.13+
- python: '3.9'
django: '3.2'
wagtail: '2.14'
experimental: false
- python: '3.9'
django: '3.2'
wagtail: '2.15'
experimental: false
- python: '3.9'
django: '3.2'
wagtail: '2.16'
experimental: false
- python: '3.9'
django: '4.0'
wagtail: '2.16'
experimental: false
- python: '3.9'
django: '3.2'
wagtail: '3.0'
experimental: false
- python: '3.9'
django: '4.0'
wagtail: '3.0'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Wagtail Localize is a translation plugin for the [Wagtail CMS](https://wagtail.o
Wagtail Localize requires the following:

- Python (3.7, 3.8, 3.9, 3.10)
- Django (2.2, 3.0, 3.1, 3.2, 4.0, 4.1)
- Wagtail (2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 3.0, 4.0) with [internationalisation enabled](https://docs.wagtail.org/en/stable/advanced_topics/i18n.html#configuration)
- Django (3.2, 4.0, 4.1)
- Wagtail (2.15, 2.16, 3.0, 4.0) with [internationalisation enabled](https://docs.wagtail.org/en/stable/advanced_topics/i18n.html#configuration)

## Installation

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ classifiers = [
dynamic = ["version"]
requires-python = ">=3.7"
dependencies = [
"Django>=2.2,<4.2",
"Wagtail>=2.11,<5.0",
"Django>=3.2,<4.2",
"Wagtail>=2.15,<5.0",
"polib>=1.1,<2.0",
"typing_extensions>=4.0"
]
Expand Down
10 changes: 2 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ skipsdist = True
usedevelop = True

envlist =
python{3.7,3.8,3.9}-django{2.2}-wagtail{2.11,2.12,2.13}-{sqlite,postgres}
python{3.7,3.8,3.9}-django{3.2}-wagtail{2.14,2.15,2.16,3.0,4.0}-{sqlite,postgres}
python{3.7,3.8,3.9,3.10}-django{4.0}-wagtail{2.16,3.0,4.0,main}-{sqlite,postgres}
python{3.7,3.8,3.9}-django{3.2}-wagtail{2.15,2.16,3.0,4.0}-{sqlite,postgres}
python{3.10}-django{3.2}-wagtail{2.15,2.16,3.0,4.0,main}-{sqlite,postgres}
python{3.7,3.8,3.9,3.10}-django{4.0}-wagtail{2.16,3.0,4.0,main}-{sqlite,postgres}
python{3.8, 3.9, 3.10}-django{4.1,main}-wagtail{4.0,main}-{sqlite,postgres}

[flake8]
Expand All @@ -29,16 +28,11 @@ deps =
coverage
typing_extensions>=4.0

django2.2: Django~=2.2
django3.2: Django~=3.2
django4.0: Django~=4.0
django4.1: Django~=4.1
djangomain: git+https://github.com/django/django.git@main#egg=Django

wagtail2.11: wagtail>=2.11,<2.12
wagtail2.12: wagtail>=2.12,<2.13
wagtail2.13: wagtail>=2.13,<2.14
wagtail2.14: wagtail>=2.14,<2.15
wagtail2.15: wagtail>=2.15,<2.16
wagtail2.16: wagtail>=2.16,<2.17
wagtail3.0: wagtail>=3.0,<4.0
Expand Down
11 changes: 4 additions & 7 deletions wagtail_localize/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from django import VERSION as DJANGO_VERSION
from .version import get_version

from .version import VERSION, __version__ # noqa

# release must be one of alpha, beta, rc, or final
VERSION = (1, 3, 0, "alpha", 3)

if DJANGO_VERSION >= (3, 2):
# The declaration is only needed for older Django versions
pass
else:
default_app_config = "wagtail_localize.apps.WagtailLocalizeAppConfig"
__version__ = get_version(VERSION)
8 changes: 0 additions & 8 deletions wagtail_localize/locales/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
from django import VERSION as DJANGO_VERSION


if DJANGO_VERSION >= (3, 2):
# The declaration is only needed for older Django versions
pass
else:
default_app_config = "wagtail_localize.locales.apps.WagtailLocalesAppConfig"
10 changes: 0 additions & 10 deletions wagtail_localize/modeladmin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
from django import VERSION as DJANGO_VERSION


if DJANGO_VERSION >= (3, 2):
# The declaration is only needed for older Django versions
pass
else:
default_app_config = (
"wagtail_localize.modeladmin.apps.WagtailLocalizeModelAdminAppConfig"
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
{% load i18n wagtailadmin_tags %}

{% block header %}
{% if wagtail_version >= "2.15" %}
{% include "modeladmin/includes/header_with_history.html" with title=view.get_page_title subtitle=view.get_page_subtitle icon=view.header_icon tabbed=1 merged=1 latest_log_entry=latest_log_entry history_url=history_url %}
{% else %}
{% include "wagtailadmin/shared/header_with_locale_selector.html" with title=view.get_page_title subtitle=view.get_page_subtitle icon=view.header_icon tabbed=1 merged=1 %}
{% endif %}
{% endblock %}

{% block form_actions %}
Expand Down
8 changes: 1 addition & 7 deletions wagtail_localize/modeladmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from django.urls import NoReverseMatch, reverse
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.contrib.modeladmin.views import (
ChooseParentView,
CreateView,
DeleteView,
EditView,
HistoryView,
IndexView,
InspectView,
)
Expand All @@ -25,12 +25,6 @@
from wagtail_localize.views.submit_translations import SubmitTranslationView


if WAGTAIL_VERSION >= (2, 15):
from wagtail.contrib.modeladmin.views import HistoryView
else:
HistoryView = object


class TranslatableViewMixin:
def __init__(self, *args, **kwargs):
self.locale = None
Expand Down
2 changes: 1 addition & 1 deletion wagtail_localize/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def as_instance(self):

if isinstance(instance, Page):
content_json = self.content_json
if WAGTAIL_VERSION >= (2, 17):
if WAGTAIL_VERSION >= (3, 0):
# see https://github.com/wagtail/wagtail/pull/8024
content_json = json.loads(content_json)
return instance.with_content_json(content_json)
Expand Down
34 changes: 12 additions & 22 deletions wagtail_localize/segments/tests/test_segment_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@
from wagtail_localize.test.models import TestChildObject, TestPage, TestSnippet


def streamfield_raw_data(stream_data):
"""
Extracts raw_data from streamfields. The attribute for doing this changed in Wagtail 2.12
"""
if WAGTAIL_VERSION >= (2, 12):
return stream_data.raw_data
else:
return stream_data.stream_data


def make_test_page(**kwargs):
root_page = Page.objects.get(id=1)
kwargs.setdefault("title", "Test page")
Expand Down Expand Up @@ -287,7 +277,7 @@ def test_charblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -317,7 +307,7 @@ def test_textblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -347,7 +337,7 @@ def test_emailblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -381,7 +371,7 @@ def test_urlblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -418,7 +408,7 @@ def test_embedblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -451,7 +441,7 @@ def test_richtextblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -485,7 +475,7 @@ def test_rawhtmlblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -515,7 +505,7 @@ def test_blockquoteblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -554,7 +544,7 @@ def test_structblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -598,7 +588,7 @@ def test_listblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -647,7 +637,7 @@ def test_nestedstreamblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down Expand Up @@ -690,7 +680,7 @@ def test_customstructblock(self):
translated_page.refresh_from_db()

self.assertEqual(
list(streamfield_raw_data(translated_page.test_streamfield)),
list(translated_page.test_streamfield.raw_data),
[
{
"id": str(block_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,33 +140,19 @@ const EditorFooter: FunctionComponent<EditorProps> = ({
// Make last action the default
const defaultAction = actions.pop();

// The markup for footers is slightly different when running Wagtail 2.13+
if ((window as any).comments) {
// Running Wagtail 2.13
return (
<footer className="footer">
<ul>
<li className="footer__container">
<ActionMenu
defaultAction={defaultAction}
actions={actions}
previewModes={previewModes}
/>
</li>
</ul>
</footer>
);
} else {
return (
<footer>
<ActionMenu
defaultAction={defaultAction}
actions={actions}
previewModes={previewModes}
/>
</footer>
);
}
return (
<footer className="footer">
<ul>
<li className="footer__container">
<ActionMenu
defaultAction={defaultAction}
actions={actions}
previewModes={previewModes}
/>
</li>
</ul>
</footer>
);
};

export default EditorFooter;
Loading