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

Wagtail 6.0 and Django 5.0 support #63

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
database: ["postgres"]

services:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -19,8 +19,8 @@ Currently supports:
- Headings

### Requirements:
* Django >= 3.2
* Wagtail >= 4.1
* Django >= 4.2
* Wagtail >= 5.2

For the full documentation, see: https://torchbox.github.io/wagtail-content-import/

Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started.md
@@ -1,6 +1,6 @@
## Requirements:
* Django 2.2
* Wagtail 2.2
* Django 4.2 or 5.0
* Wagtail 5.2 or 6.0

### To set up:
1. Run `python3 pip install wagtail-content-import`.
Expand Down
8 changes: 1 addition & 7 deletions docs/submitting_backend.md
Expand Up @@ -116,13 +116,7 @@ Eg:

```

#### `__init__.py` and `apps.py`

`init.py`:

```python
default_app_config = 'wagtail_content_import.pickers.my_picker.apps.WagtailContentImportMyPickerAppConfig'
```
#### `apps.py`

`apps.py`:

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -37,18 +37,20 @@
"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",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Wagtail",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
"Framework :: Wagtail :: 6",
"Topic :: Internet :: WWW/HTTP :: Site Management",
],
install_requires=["wagtail>=4.1", "python-docx>=0.8.10"],
Expand Down
16 changes: 7 additions & 9 deletions tox.ini
Expand Up @@ -2,19 +2,19 @@
skipsdist = True
usedevelop = True
envlist =
python{3.8,3.9,3.10}-django{3.2,4.1}-wagtail{4.1,5.0,5.1,main}-{sqlite,postgres}
python3.11-django4.1-wagtail{4.1,main}-{sqlite,postgres}
python{3.8,3.9,3.10,3.11}-django{4.1,4.2}-wagtail{5.0,5.1,main}-{sqlite,postgres}
python{3.8,3.9,3.10,3.11}-django4.2-wagtail{5.2,6.0}-{sqlite,postgres}
python{3.10,3.11,3.12}-django5.0-wagtail{5.2,6.0,main}-{sqlite,postgres}

[gh-actions]
python =
3.8: python3.8
3.9: python3.9
3.10: python3.10
3.11: python3.11
3.12: python3.12

[gh-actions:env]
DATABASE =
DATABASE =
postgres: postgres

[flake8]
Expand All @@ -30,13 +30,11 @@ commands = coverage run testmanage.py test --deprecation all
deps =
coverage

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.0: wagtail>=5.0,<5.1
wagtail5.1: wagtail>=5.1,<5.2
wagtail5.2: wagtail>=5.2,<6.0
wagtail6.0: wagtail>=6.0,<6.1
wagtailmain: git+https://github.com/wagtail/wagtail.git

postgres: psycopg2
Expand Down
2 changes: 0 additions & 2 deletions wagtail_content_import/__init__.py
@@ -1,3 +1 @@
__version__ = "0.1a0"

default_app_config = "wagtail_content_import.apps.WagtailContentImportAppConfig"
1 change: 0 additions & 1 deletion wagtail_content_import/pickers/google/__init__.py
@@ -1 +0,0 @@
default_app_config = "wagtail_content_import.pickers.google.apps.WagtailContentImportGooglePickerAppConfig"
3 changes: 0 additions & 3 deletions wagtail_content_import/pickers/local/__init__.py
@@ -1,3 +0,0 @@
default_app_config = (
"wagtail_content_import.pickers.local.apps.WagtailContentImportLocalPickerAppConfig"
)
1 change: 0 additions & 1 deletion wagtail_content_import/pickers/microsoft/__init__.py
@@ -1 +0,0 @@
default_app_config = "wagtail_content_import.pickers.microsoft.apps.WagtailContentImportMicrosoftPickerAppConfig"
Expand Up @@ -4,9 +4,22 @@
color: #262626;
}

.button.content-import + .w-dropdown--dropdown-button button,
.button.content-import + .dropdown-toggle {
background-color: #fafafa;
border: none;
border-left: 1px solid #007d7e;
color: #262626;
}

.button.content-import:hover, .content-import.dropdown-toggle:hover{
background-color: #ececec;
}
}

.button.content-import + .w-dropdown--dropdown-button button:hover,
.button.content-import + .dropdown-toggle:hover {
background-color: #ececec;
}

.docs-blue.content-import {
color: #4387f4;
Expand Down
@@ -0,0 +1,5 @@
<li class="actions actions--primary">
<div class="dropdown dropup dropdown-button match-width">
{% include "wagtailadmin/pages/action_menu/menu.html" %}
</div>
</li>
@@ -0,0 +1,9 @@
{% load wagtailadmin_tags %}
<a href="#"
data-content-import-picker="{{ name }}"
data-import-page-url="{{ url }}"
{% if show_dialog %}data-dialog-url="{% url 'wagtail_content_import_admin:confirm_dialog' %}"{% endif %}
class="content-import button button-longrunning">
{% if icon_name %}{% icon name=icon_name classname="icon content-import docs-blue" %}{% endif %}
{{ label }}
</a>

This file was deleted.

This file was deleted.

This file was deleted.

74 changes: 56 additions & 18 deletions wagtail_content_import/templatetags/wagtailcontentimport_tags.py
@@ -1,6 +1,9 @@
import re
from django import template
from django.urls import reverse
from django.utils.safestring import mark_safe
from wagtail import hooks
from wagtail import hooks, VERSION as WAGTAIL_VERSION
from wagtail.admin.action_menu import ActionMenuItem

register = template.Library()

Expand All @@ -18,25 +21,60 @@ def wagtailcontentimport_pickerjs(context):
return mark_safe("\n".join(js_snippets))


@register.inclusion_tag(
"wagtail_content_import/picker_buttons_create.html", takes_context=True
)
def wagtailcontentimport_picker_buttons_create(context):
class ImportMenuItem(ActionMenuItem):
template_name = "wagtail_content_import/import_menu_item.html"

def __init__(self, picker):
super().__init__()
self.label = "Import from %s" % picker.verbose_name
self.icon_name = re.sub(r'^icon-', '', picker.icon)
self.name = picker.name

def get_context_data(self, parent_context):
context = super().get_context_data(parent_context)
context["show_dialog"] = (parent_context["view"] != "create")
return context

def get_url(self, parent_context):
if parent_context["view"] == "create":
return reverse("wagtailadmin_pages:add", args=[
parent_context["content_type"].app_label,
parent_context["content_type"].model,
parent_context["parent_page"].id
])
else:
return reverse("wagtailadmin_pages:edit", args=[parent_context["page"].id])


def get_picker_buttons_context(context, view):
pickers = [fn() for fn in hooks.get_hooks("register_content_import_picker") if fn()]
if pickers:
context["default_picker"] = pickers[0]
if len(pickers) > 1:
context["picker_options"] = pickers[1:]
menu_items = [ImportMenuItem(picker) for picker in pickers]
flat_context = context.flatten()
flat_context["view"] = view
rendered_menu_items = [item.render_html(flat_context) for item in menu_items]

try:
default_item = rendered_menu_items.pop(0)
except IndexError:
default_item = None

context["show_menu"] = bool(rendered_menu_items)
context["rendered_menu_items"] = rendered_menu_items
context["default_menu_item"] = default_item
return context


@register.inclusion_tag(
"wagtail_content_import/picker_buttons_edit.html", takes_context=True
)
if WAGTAIL_VERSION >= (6, 0):
action_menu_template = "wagtailadmin/pages/action_menu/menu.html"
else:
action_menu_template = "wagtail_content_import/action_menu_wrapper.html"


@register.inclusion_tag(action_menu_template, takes_context=True)
def wagtailcontentimport_picker_buttons_create(context):
return get_picker_buttons_context(context, "create")


@register.inclusion_tag(action_menu_template, takes_context=True)
def wagtailcontentimport_picker_buttons_edit(context):
pickers = [fn() for fn in hooks.get_hooks("register_content_import_picker") if fn()]
if pickers:
context["default_picker"] = pickers[0]
if len(pickers) > 1:
context["picker_options"] = pickers[1:]
return context
return get_picker_buttons_context(context, "edit")