diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b4c1b3..d524eee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Wagtail Footnotes Changelog +## 0.8.0 + + - Add support for Wagtail 3.0 and drop support for all Wagtail versions + before 2.15 + - Dropped support for all Django versions + before 3.2 + - Removed support for Python 3.6 + - Fix previews https://github.com/torchbox/wagtail-footnotes/pull/24 - [@jsma](https://github.com/jsma) + ## 0.7.0 - Clean up old step from README - It is no longer recommended to define footnotes in `WAGTAILADMIN_RICH_TEXT_EDITORS` diff --git a/setup.cfg b/setup.cfg index 23c6cef..8c96201 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,8 +2,8 @@ name = wagtail-footnotes author = Cameron Lamb author_email = cameron.lamb@torchbox.com -description = Add footnotes to rich text in your wagtail pages -version = 0.7.0 +description = Add footnotes to rich text in your Wagtail pages +version = 0.8.1 url = https://github.com/torchbox/wagtail-footnotes keywords = wagtail @@ -14,12 +14,11 @@ license_files = LICENSE.txt [options] -python_requires = >= 3.6 +python_requires = >= 3.7 setup_requires = setuptools >= 40.6 pip >= 10 include_package_data = true packages = find: install_requires = - Django>=2.2, <3.3 - wagtail>=2.5, <3 + wagtail>=2.15, <4.0 diff --git a/setup.py b/setup.py index 6068493..5b51a7a 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ from setuptools import setup -setup() +# Redefine `name` here so GitHub’s "Used By" can detect the package. +setup(name="wagtail-footnotes") diff --git a/wagtail_footnotes/blocks.py b/wagtail_footnotes/blocks.py index a6c339a..8dd1aeb 100644 --- a/wagtail_footnotes/blocks.py +++ b/wagtail_footnotes/blocks.py @@ -3,8 +3,18 @@ from django.core.exceptions import ValidationError from django.utils.safestring import mark_safe -from wagtail.core.blocks import RichTextBlock -from wagtail.core.models import Page + +try: + from wagtail.blocks import RichTextBlock +except ImportError: + # Wagtail<3.0 + from wagtail.core.blocks import RichTextBlock + +try: + from wagtail.models import Page +except ImportError: + from wagtail.core.models import Page + FIND_FOOTNOTE_TAG = re.compile(r'.*?') @@ -40,7 +50,7 @@ def replace_footnote_tags(self, value, html, context=None): page.footnotes_list = [] if not hasattr(page, "footnotes_references"): page.footnotes_references = defaultdict(list) - self.footnotes = {footnote.uuid: footnote for footnote in page.footnotes.all()} + self.footnotes = {str(footnote.uuid): footnote for footnote in page.footnotes.all()} def replace_tag(match): footnote_uuid = match.group(1) diff --git a/wagtail_footnotes/migrations/0001_initial.py b/wagtail_footnotes/migrations/0001_initial.py index 7384ad4..02d3ae7 100644 --- a/wagtail_footnotes/migrations/0001_initial.py +++ b/wagtail_footnotes/migrations/0001_initial.py @@ -2,10 +2,17 @@ import django.db.models.deletion import modelcluster.fields -import wagtail.core.fields -import wagtail_footnotes.fields + +try: + import wagtail.fields as wagtail_fields +except ImportError: + # Wagtail<3.0 + import wagtail.core.fields as wagtail_fields + from django.db import migrations, models +import wagtail_footnotes.fields + class Migration(migrations.Migration): @@ -36,7 +43,7 @@ class Migration(migrations.Migration): verbose_name="ID", ), ), - ("text", wagtail.core.fields.RichTextField()), + ("text", wagtail_fields.RichTextField()), ( "page", modelcluster.fields.ParentalKey( diff --git a/wagtail_footnotes/migrations/0002_alter_footnote_unique_together.py b/wagtail_footnotes/migrations/0002_alter_footnote_unique_together.py index 02503b8..fa7991b 100644 --- a/wagtail_footnotes/migrations/0002_alter_footnote_unique_together.py +++ b/wagtail_footnotes/migrations/0002_alter_footnote_unique_together.py @@ -1,6 +1,7 @@ # Generated by Django 3.2.4 on 2021-06-24 10:18 from django.db import migrations + import wagtail_footnotes.fields diff --git a/wagtail_footnotes/models.py b/wagtail_footnotes/models.py index cc87a5a..fea3b83 100644 --- a/wagtail_footnotes/models.py +++ b/wagtail_footnotes/models.py @@ -1,8 +1,18 @@ from django.conf import settings from django.db import models from modelcluster.fields import ParentalKey -from wagtail.admin.edit_handlers import FieldPanel, InlinePanel -from wagtail.core.fields import RichTextField + +try: + from wagtail.admin.panels import FieldPanel, InlinePanel +except ImportError: + # Wagtail<3.0 + from wagtail.admin.edit_handlers import FieldPanel, InlinePanel + +try: + from wagtail.fields import RichTextField +except ImportError: + # Wagtail<3.0 + from wagtail.core.fields import RichTextField from .fields import CustomUUIDField from .widgets import ReadonlyUUIDInput diff --git a/wagtail_footnotes/wagtail_hooks.py b/wagtail_footnotes/wagtail_hooks.py index 270cd5b..093e82a 100644 --- a/wagtail_footnotes/wagtail_hooks.py +++ b/wagtail_footnotes/wagtail_hooks.py @@ -2,10 +2,14 @@ from django.templatetags.static import static from django.utils.html import format_html_join from draftjs_exporter.dom import DOM -from wagtail.admin.rich_text.converters.html_to_contentstate import ( - InlineEntityElementHandler, -) -from wagtail.core import hooks +from wagtail.admin.rich_text.converters.html_to_contentstate import \ + InlineEntityElementHandler + +try: + from wagtail import hooks +except ImportError: + # Wagtail<3.0 + from wagtail.core import hooks @hooks.register("register_rich_text_features")