Skip to content

Commit

Permalink
Merge pull request #5 from torchbox-forks/support/wagtail-52
Browse files Browse the repository at this point in the history
Support/wagtail 52
  • Loading branch information
katdom13 authored Nov 17, 2023
2 parents 37040e6 + 424c530 commit 5ca6e43
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 140 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ jobs:
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
wagtail-version:
- "2.15.6"
- "4.1.2"
- "4.1"
- "4.2"
exclude:
- python-version: "3.11"
wagtail-version: "2.15.6"
- "5.0"
- "5.1"
- "5.2"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -39,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --verbose"
Expand All @@ -50,8 +48,8 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
Expand All @@ -64,8 +62,8 @@ jobs:
runs-on: ubuntu-latest
needs: [test, lint-black, lint-isort]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
- Add Wagtail >= 5.0 support (@katdom13)
- Add Python 4.2 support (@katdom13)
- Add Python 3.11 support (@katdom13)

### Changed
### Fixed
### Removed
- Drop Wagtail < 4.1 support (@katdom13)
- Drop Django 4.0 support (@katdom13)
- Drop Python 3.7 support (@katdom13)

## [1.4.1] - 2023-02-19
### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Introduces panels for selecting colors in Wagtail.
## Example

```python
from wagtail.core.models import Page
from wagtail.models import Page

from wagtail_color_panel.fields import ColorField
from wagtail_color_panel.edit_handlers import NativeColorPanel
Expand Down
4 changes: 2 additions & 2 deletions docs/1_getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Requirements

- Python 3.7+
- Wagtail 2.15+ and Django
- Python 3.8+
- Wagtail 4.1+ and Django 3.2+
- [A browser that supports `input type="color"`](https://caniuse.com/#feat=input-color)


Expand Down
8 changes: 4 additions & 4 deletions docs/2_adding_to_a_page.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### First create a page

```python
from wagtail.core.models import Page
from wagtail.models import Page

class MyPage(Page):
...
Expand All @@ -15,7 +15,7 @@ class MyPage(Page):
Define a ColorField that represents your color, in this example we call it `color`.

```python
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail_color_panel.fields import ColorField

class MyPage(Page):
Expand All @@ -28,7 +28,7 @@ Note: ColorField is built on top of CharField, so its also possible to use `Char
### Add a content panel to represent the field in the admin

```python
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail_color_panel.edit_handlers import NativeColorPanel


Expand All @@ -46,7 +46,7 @@ We're done! After migration a color picker should appear.
### Full example

```python
from wagtail.core.models import Page
from wagtail.models import Page

from wagtail_color_panel.fields import ColorField
from wagtail_color_panel.edit_handlers import NativeColorPanel
Expand Down
8 changes: 4 additions & 4 deletions docs/3_adding_to_a_streamfield.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
To add the color chooser to a StreamField, import and use the `NativeColorBlock`.

```python
from wagtail.core.models import Page
from wagtail.core.fields import StreamField
from wagtail.models import Page
from wagtail.fields import StreamField
from wagtail_color_panel.blocks import NativeColorBlock


class MyStreamFieldPage(Page):
body = StreamField([
('color', NativeColorBlock(default="#000000")),
])
], use_json_field=True)

content_panels = Page.content_panels + [
StreamFieldPanel('body'),
FieldPanel('body'),
]
```
14 changes: 7 additions & 7 deletions docs/4_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This panel uses the native `<input type="color"...` color selector (hence the na
#### How to use

```python
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail_color_panel.edit_handlers import NativeColorPanel

class MyPage(Page):
Expand All @@ -28,7 +28,7 @@ This panel uses the third party package [Spectrum](https://github.com/bgrins/spe
#### How to use

```python
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail_color_panel.edit_handlers import PolyfillColorPanel

class MyPage(Page):
Expand All @@ -49,7 +49,7 @@ A field based on CharField that only accept color values saved as hex values (ex
#### How to use

```python
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail_color_panel.fields import ColorField

class MyPage(Page):
Expand All @@ -66,17 +66,17 @@ This block uses the native `<input type="color"...` color selector (hence the na
#### How to use

```python
from wagtail.core.models import Page
from wagtail.core.fields import StreamField
from wagtail.models import Page
from wagtail.fields import StreamField
from wagtail_color_panel.blocks import NativeColorBlock


class MyStreamFieldPage(Page):
body = StreamField([
('color', NativeColorBlock(default="#000000")),
])
], use_json_field=True)

content_panels = Page.content_panels + [
StreamFieldPanel('body'),
FieldPanel('body'),
]
```
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import find_packages, setup

install_requires = ["wagtail>=2.15"]
install_requires = ["wagtail>=4.1"]

tests_require = ["pytest-django", "wagtail-factories", "pytest"]

Expand Down Expand Up @@ -40,21 +40,19 @@
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Wagtail",
"Framework :: Wagtail :: 2",
"Framework :: Wagtail :: 3",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"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",
"Topic :: Utilities",
],
setup_requires=["setuptools_scm", "pytest-runner"],
python_requires=">=3.7",
python_requires=">=3.8",
)
4 changes: 1 addition & 3 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from wagtail import VERSION as WAGTAIL_VERSION

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

ADMINS = (("test@example.com", "test"),)
Expand All @@ -26,7 +24,7 @@
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail" if WAGTAIL_VERSION >= (3, 0) else "wagtail.core",
"wagtail",
"modelcluster",
"taggit",
"django.contrib.admin",
Expand Down
7 changes: 1 addition & 6 deletions tests/test_block.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
from django.core.exceptions import ValidationError
from django.test import TestCase
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.test.utils import WagtailTestUtils

from wagtail_color_panel.blocks import NativeColorBlock
from wagtail_color_panel.widgets import ColorInputWidget

if WAGTAIL_VERSION >= (3, 0):
from wagtail.test.utils import WagtailTestUtils
else:
from wagtail.tests.utils import WagtailTestUtils


class BlockTest(TestCase, WagtailTestUtils):
def test_color_block_render(self):
Expand Down
7 changes: 1 addition & 6 deletions tests/test_field.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
from django.core.exceptions import ValidationError
from django.test import TestCase
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.test.utils import WagtailTestUtils

from tests.testapp.factories import (
PageWithColorFieldPageFactory,
PageWithDefaultValuePageFactory,
)

if WAGTAIL_VERSION >= (3, 0):
from wagtail.test.utils import WagtailTestUtils
else:
from wagtail.tests.utils import WagtailTestUtils


class FieldTest(TestCase, WagtailTestUtils):
def test_strings_larger_than_7_raises_error(self):
Expand Down
9 changes: 2 additions & 7 deletions tests/test_widget.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
from django.test import TestCase
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.test.utils import WagtailTestUtils

from tests.testapp.factories import PageWithColorFieldPageFactory
from wagtail_color_panel.edit_handlers import NativeColorPanel
from wagtail_color_panel.widgets import ColorInputWidget

if WAGTAIL_VERSION >= (3, 0):
from wagtail.test.utils import WagtailTestUtils
else:
from wagtail.tests.utils import WagtailTestUtils

# from wagtail.admin.panels import get_form_for_model
# from wagtail.admin.forms import WagtailAdminModelForm, WagtailAdminPageForm

Expand All @@ -30,5 +25,5 @@ def test_native_color_panel_uses_correct_widget(self):
color_panel = page.content_panels[1]
self.assertEqual(color_panel.__class__, NativeColorPanel)

color_widget = color_panel.widget_overrides()["color"]
color_widget = color_panel.get_form_options()["widgets"]["color"]
self.assertEqual(color_widget.__class__, ColorInputWidget)
7 changes: 1 addition & 6 deletions tests/testapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# Generated by Django 3.0.7 on 2020-07-31 06:52
from wagtail import VERSION as WAGTAIL_VERSION
from django.db import migrations, models
import django.db.models.deletion
import wagtail_color_panel.blocks
import wagtail_color_panel.fields

if WAGTAIL_VERSION >= (3, 0):
import wagtail.fields as wagtail_fields
else:
import wagtail.core.fields as wagtail_fields
import wagtail.fields as wagtail_fields


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
11 changes: 1 addition & 10 deletions tests/testapp/migrations/0002_alter_pagewithstreamfield_body.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# Generated by Django 3.2.13 on 2022-06-23 02:07
from wagtail import VERSION as WAGTAIL_VERSION
from django.db import migrations

if WAGTAIL_VERSION >= (3, 0):
import wagtail.fields as wagtail_fields
else:
import wagtail.core.fields as wagtail_fields
import wagtail.fields as wagtail_fields
import wagtail_color_panel.blocks


class Migration(migrations.Migration):

dependencies = [
("testapp", "0001_initial"),
]
Expand All @@ -22,10 +17,6 @@ class Migration(migrations.Migration):
field=wagtail_fields.StreamField(
[("color", wagtail_color_panel.blocks.NativeColorBlock())],
use_json_field=True,
)
if WAGTAIL_VERSION >= (3, 0)
else wagtail_fields.StreamField(
[("color", wagtail_color_panel.blocks.NativeColorBlock())]
),
),
]
Loading

0 comments on commit 5ca6e43

Please sign in to comment.