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

Add Wagtail 6 support #776

Merged
merged 9 commits into from
Feb 11, 2024
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
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:

- run: pip install flit
- run: flit install --deps production --extras testing
- run: pip install "wagtail_modeladmin<2.0"

- type: cache-save
key: pip-{{ .Branch }}-{{ epoch }}
Expand Down
21 changes: 12 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ dynamic = ["version"]
requires-python = ">=3.8"
dependencies = [
"Django>=3.2,<5.1",
"Wagtail>=4.1",
"Wagtail>=5.2",
"polib>=1.1,<2.0",
"typing_extensions>=4.0"
]

[project.optional-dependencies]
testing = [
"dj-database-url>=2.1.0,<3",
"freezegun>=1.2,<2",
"django-rq>=2.5,<3.0",
"google-cloud-translate>=3.0.0",
"pre-commit>=3.4,<4"
google = [
"google-cloud-translate>=3.0.0"
]
documentation = [
"mkdocs==1.4.3",
Expand All @@ -55,8 +51,15 @@ documentation = [
"mkdocs-include-markdown-plugin>=4.0.4,<5",
"pygments>=2.15,<2.16",
]
google = [
"google-cloud-translate>=3.0.0"
testing = [
"dj-database-url>=2.1.0,<3",
"freezegun>=1.2,<2",
"django-rq>=2.5,<3.0",
"google-cloud-translate>=3.0.0",
"wagtail-modeladmin>=2.0,<3.0",
]
linting = [
"pre-commit>=3.4,<4"
]

[project.urls]
Expand Down
15 changes: 5 additions & 10 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.8,3.9,3.10}-django{3.2,4.1}-wagtail{4.1}-{sqlite,postgres12}
python{3.8,3.9,3.10,3.11}-django{4.2}-wagtail{5.1,5.2}-{sqlite,postgres15}
python{3.12}-django{4.2}-wagtail{5.2}-{sqlite,postgres15}
python{3.10,3.11,3.12}-django{5.0}-wagtail{5.2}-{sqlite,postgres15}
python{3.10}-django{3.2}-wagtail{5.2}-{sqlite,postgres15}
python{3.8,3.9,3.10,3.11,3.12}-django{4.2}-wagtail{5.2,6.0}-{sqlite,postgres15}
python{3.10,3.11,3.12}-django{5.0}-wagtail{5.2,6.0}-{sqlite,postgres15}

[gh-actions]
python =
Expand Down Expand Up @@ -38,17 +37,13 @@ deps =
typing_extensions>=4.0

django3.2: Django>=3.2,<3.3
django4.1: Django>=4.1,<4.2
django4.2: Django>=4.2,<5.0
django5.0: Django>=5.0,<5.1

wagtail4.1: wagtail>=4.1,<4.2
wagtail5.1: wagtail>=5.1,<5.2
wagtail5.2: wagtail>=5.2.2,<5.3
wagtail6.0: wagtail>=6.0,<6.1
wagtailmain: git+https://github.com/wagtail/wagtail.git

wagtail{5.1,5.2,main}: wagtail_modeladmin<2.0

postgres: psycopg2>=2.9

.[testing]
Expand Down Expand Up @@ -87,7 +82,7 @@ basepython = python3.9
# always generate with the min supported versions
deps =
Django~=3.2
wagtail>=4.1,<4.2
wagtail>=5.2,<6.0

commands =
python {toxinidir}/testmanage.py makemigrations

This file was deleted.

4 changes: 0 additions & 4 deletions wagtail_localize/locales/templates/wagtaillocales/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
<a href="{% url 'wagtaillocales:edit' locale.id %}">{{ locale }}</a>
{% if not locale.language_code_is_valid %}
{% trans "This locale's language code is not supported" as error %}
{% if wagtail_version >= "5.1" %}
{% include "wagtaillocales/_icon.html" with error=error only %}
{% else %}
{% include "wagtaillocales/_icon_legacy.html" with error=error only %}
{% endif %}
{% endif %}
</div>
</td>
Expand Down
8 changes: 6 additions & 2 deletions wagtail_localize/machine_translators/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ def walk(soup):
if isinstance(child, NavigableString):
# Translate navigable strings
child.string.replace_with(translate_string(child.string))

else:
walk(child)

# Reverse the children
if isinstance(soup, Tag):
soup.contents.reverse()
# reverse the children
reversed_contents = soup.contents[::-1]

soup = BeautifulSoup("", "html.parser")
for content in reversed_contents:
soup.append(content)

walk(soup)

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<a{% if button.url %} href="{{ button.url }}{% if locale %}?locale={{ locale.language_code }}{% endif %}"{% endif %} class="{{ button.classname }}" title="{{ button.title }}"{% if button.target %} target="{{ button.target }}"{% endif %}{% if button.rel %} rel="{{ button.rel }}"{% endif %}>{{ button.label }}</a>
{% load wagtailadmin_tags %}
<a{% if button.url %} href="{{ button.url }}{% if locale %}?locale={{ locale.language_code }}{% endif %}"{% endif %} class="{{ button.classname }}" title="{{ button.title }}"{% if button.target %} target="{{ button.target }}"{% endif %}{% if button.rel %} rel="{{ button.rel }}"{% endif %}>{% if icon %}<span class="icon-wrapper">{% icon name=icon %}</span> {% endif %}{{ button.label }}</a>
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,13 @@
{% 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 %}
{% endblock %}

{% block form_actions %}
<div class="dropdown dropup dropdown-button match-width">
{# TODO: remove data-clicked-text once we drop support for Wagtail 4.x #}
<button type="submit" class="button action-save button-longrunning" data-clicked-text="{% trans 'Saving…' %}" data-controller="w-progress" data-action="w-progress#activate" data-w-progress-active-value="{% trans 'Saving…' %}">
{% icon name="spinner" %}<em>{% trans "Save" %}</em>
</button>
{% block more_action_items %}
{{ block.super }}

{% if user_can_delete %}
<div class="dropdown-toggle">{% icon name="arrow-up" %}</div>
<ul>
{% if translation %}
<li>
<form method="POST">
<input type="hidden" name="localize-restart-translation">
<button class="button">{% trans "Start Synced translation" %}</button>
</form>
</li>
{% endif %}
<li><a href="{{ view.delete_url }}" class="shortcut">{% trans "Delete" %}</a></li>
</ul>
{% if user_can_delete and translation %}
<form method="POST">
<input type="hidden" name="localize-restart-translation">
<button class="button">{% trans "Start Synced translation" %}</button>
</form>
{% endif %}

</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
{% load i18n modeladmin_tags wagtailadmin_tags %}

{% block header_extra %}
<div class="right header-right">
<div class="col">
{% include 'wagtailadmin/shared/locale_selector.html' with class='c-dropdown--large' %}
</div>
{% if not translations %}<div class="button button-secondary">{% endif %}
{% include 'wagtailadmin/shared/locale_selector.html' with class='c-dropdown--large' theme="large" %}
{% if not translations %}</div>{% endif %}
{% if user_can_create %}
<div class="actionbutton col">
{% include 'wagtail_localize/modeladmin/includes/button.html' with button=view.button_helper.add_button %}
</div>
{% include 'wagtail_localize/modeladmin/includes/button.html' with button=view.button_helper.add_button icon="plus" %}
{% endif %}
{% if view.list_export %}
<div class="dropdown dropdown-button match-width col">
<a href="?export=xlsx&{{ request.GET.urlencode }}" class="button bicolor button--icon">{% icon name="download" wrapped=1 %}{% trans 'Download XLSX' %}</a>
<div class="dropdown-toggle">{% icon name="arrow-down" %}</div>
<ul>
<li><a class="button bicolor button--icon" href="?export=csv&{{ request.GET.urlencode }}">{% icon name="download" wrapped=1 %}{% trans 'Download CSV' %}</a></li>
</ul>
</div>
{% include view.export_buttons_template_name %}
{% endif %}
</div>
{% endblock %}
31 changes: 9 additions & 22 deletions wagtail_localize/modeladmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,21 @@
from django.utils.translation import gettext as _
from wagtail.models import Locale, TranslatableMixin
from wagtail.utils.version import get_main_version
from wagtail_modeladmin.views import (
ChooseParentView,
CreateView,
DeleteView,
EditView,
HistoryView,
IndexView,
InspectView,
)

from wagtail_localize.models import Translation
from wagtail_localize.views import edit_translation
from wagtail_localize.views.submit_translations import SubmitTranslationView


try:
from wagtail_modeladmin.views import (
ChooseParentView,
CreateView,
DeleteView,
EditView,
HistoryView,
IndexView,
InspectView,
)
except ImportError:
from wagtail.contrib.modeladmin.views import (
ChooseParentView,
CreateView,
DeleteView,
EditView,
HistoryView,
IndexView,
InspectView,
)


class TranslatableViewMixin:
def __init__(self, *args, **kwargs):
self.locale = None
Expand Down
Loading
Loading