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 3.0 compatibility #48

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a major release, right? We need to add the new version number here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the final release number should now be 1.0.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay cool.

- [Wagtail 3.0 compatibility](https://github.com/torchbox/wagtail-ab-testing/pull/48)

## [0.7] - 2022-03-31

- [Add default_auto_field](https://github.com/torchbox/wagtail-ab-testing/pull/42)
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Key features:

## Usage

**The code examples below assume you are using Wagtail v3.0+** If you need information for an earlier version of Wagtail see the [Release notes](https://docs.wagtail.org/en/stable/releases/upgrading.html) for guidance.

Wagtail A/B Testing works with Django 2.2+, Wagtail 2.11+ on Python 3.7+ environments.

### Creating an A/B test

Any user with the "Create A/B test" permission can create an A/B test by clicking "Save and create A/B test" from the page's action menu.
Expand Down Expand Up @@ -72,7 +76,7 @@ from wagtail_ab_testing import urls as ab_testing_urls
urlpatterns = [
...

url(r'^abtesting/', include(ab_testing_urls)),
path('abtesting/', include(ab_testing_urls)),
]
```

Expand All @@ -99,7 +103,7 @@ add your goal type to the list of options shown to users when they create A/B te
```python
# myapp/wagtail_hooks.py

from wagtail.core import hooks
from wagtail import hooks
from wagtail_ab_testing.events import BaseEvent


Expand Down Expand Up @@ -143,7 +147,7 @@ Firstly, we need to register the event type. To do this, implement a handler for
```python
# myapp/wagtail_hooks.py

from wagtail.core import hooks
from wagtail import hooks
from wagtail_ab_testing.events import BaseEvent

from .models import ContactUsFormPage
Expand Down
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,25 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Wagtail",
"Framework :: Wagtail :: 2",
"Framework :: Wagtail :: 3.0",
],
install_requires=[
"Django>=2.2,<3.3",
"Wagtail>=2.11,<2.17",
"Django>=2.2,<4.1",
"Wagtail>=2.11,<4.0",
"user-agents>=2.2,<2.3",
"numpy>=1.19.4,<1.20",
"scipy>=1.5.4,<1.6",
"numpy>=1.19.4,<1.23",
"scipy>=1.5.4,<1.9",
],
extras_require={
"testing": ["dj-database-url==0.5.0", "freezegun==0.3.15"],
"testing": ["dj-database-url==0.5.0", "freezegun==1.2.1"],
},
zip_safe=False,
)
7 changes: 5 additions & 2 deletions testmanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

from django.core.management import execute_from_command_line

try:
from wagtail.test.settings import STATIC_ROOT, MEDIA_ROOT
except ImportError:
nickmoreton marked this conversation as resolved.
Show resolved Hide resolved
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT


os.environ["DJANGO_SETTINGS_MODULE"] = "wagtail_ab_testing.test.settings"

Expand Down Expand Up @@ -56,8 +61,6 @@ def runtests():
try:
execute_from_command_line(argv)
finally:
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)

Expand Down
12 changes: 8 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
skipsdist = True
usedevelop = True

envlist = py{37,38,39}-dj{22,30,32,main}-wa{211,215,216,main}-{sqlite,postgres}
envlist = py{37,38,39}-dj{22,30,32,40,main}-wa{211,215,216,30,main}-{sqlite,postgres}

[flake8]
# E501: Line too long
Expand All @@ -17,21 +17,25 @@ commands = coverage run testmanage.py test --deprecation all
basepython =
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10

deps =
coverage

dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
dj32: Django>=3.2,<3.3
dj40: Django>=4.0,<4.1
djmain: git+https://github.com/django/django.git@main#egg=Django

wa211: wagtail>=2.11,<2.12
wa215: wagtail>=2.15rc1,<2.16
wa216: wagtail>=2.16.1,<2.17
wa215: wagtail>=2.15,<2.16
wa216: wagtail>=2.16,<2.17
wa30: wagtail>=3.0,<4.0
wamain: git+https://github.com/wagtail/wagtail.git

postgres: psycopg2==2.8.6
postgres: psycopg2==2.9.3

setenv =
postgres: DATABASE_URL=postgres:///wagtail_ab_testing
Expand Down
6 changes: 5 additions & 1 deletion wagtail_ab_testing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from rest_framework import fields, routers, serializers, status, viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
from wagtail.core.models import Page, Site

try:
from wagtail.models import Page, Site
except ImportError:
from wagtail.core.models import Page, Site
nickmoreton marked this conversation as resolved.
Show resolved Hide resolved

from .models import AbTest

Expand Down
5 changes: 4 additions & 1 deletion wagtail_ab_testing/events.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from django.utils.translation import gettext_lazy as __

from wagtail.core import hooks
try:
from wagtail import hooks
except ImportError:
from wagtail.core import hooks
nickmoreton marked this conversation as resolved.
Show resolved Hide resolved


class BaseEvent:
Expand Down
6 changes: 5 additions & 1 deletion wagtail_ab_testing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext as _, gettext_lazy as __
from wagtail.core.signals import page_unpublished

try:
from wagtail.signals import page_unpublished
except ImportError:
from wagtail.core.signals import page_unpublished

from .events import get_event_types

Expand Down
5 changes: 4 additions & 1 deletion wagtail_ab_testing/test/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from wagtail.core.models import Page
try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page


class SimplePage(Page):
Expand Down
6 changes: 5 additions & 1 deletion wagtail_ab_testing/test/tests/test_abtest_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

from django.test import TestCase
from freezegun import freeze_time
from wagtail.core.models import Page

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

from wagtail_ab_testing.models import AbTest, AbTestHourlyLog

Expand Down
12 changes: 10 additions & 2 deletions wagtail_ab_testing/test/tests/test_add_abtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.urls import reverse
from wagtail.core.models import Page
from wagtail.tests.utils import WagtailTestUtils

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

try:
from wagtail.test.utils import WagtailTestUtils
except ImportError:
from wagtail.tests.utils import WagtailTestUtils

from wagtail_ab_testing.models import AbTest
from wagtail_ab_testing.test.models import SimplePage
Expand Down
6 changes: 5 additions & 1 deletion wagtail_ab_testing/test/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from django.urls import reverse
from freezegun import freeze_time
from rest_framework.test import APITestCase
from wagtail.core.models import Page

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

from wagtail_ab_testing.models import AbTest
from wagtail_ab_testing.test.models import SimplePage
Expand Down
12 changes: 10 additions & 2 deletions wagtail_ab_testing/test/tests/test_compare_draft.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from django.test import TestCase
from django.urls import reverse
from wagtail.core.models import Page
from wagtail.tests.utils import WagtailTestUtils

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

try:
from wagtail.test.utils import WagtailTestUtils
except ImportError:
from wagtail.tests.utils import WagtailTestUtils

from wagtail_ab_testing.models import AbTest
from wagtail_ab_testing.test.models import SimplePage
Expand Down
12 changes: 10 additions & 2 deletions wagtail_ab_testing/test/tests/test_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.urls import reverse
from wagtail.core.models import Page
from wagtail.tests.utils import WagtailTestUtils

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

try:
from wagtail.test.utils import WagtailTestUtils
except ImportError:
from wagtail.tests.utils import WagtailTestUtils

from wagtail_ab_testing.models import AbTest
from wagtail_ab_testing.test.models import SimplePage
Expand Down
12 changes: 10 additions & 2 deletions wagtail_ab_testing/test/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.urls import reverse
from wagtail.core.models import Page
from wagtail.tests.utils import WagtailTestUtils

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

try:
from wagtail.test.utils import WagtailTestUtils
except ImportError:
from wagtail.tests.utils import WagtailTestUtils

from wagtail_ab_testing.models import AbTest
from wagtail_ab_testing.test.models import SimplePage
Expand Down
12 changes: 10 additions & 2 deletions wagtail_ab_testing/test/tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from django.urls import reverse
from wagtail.core.models import Page
from wagtail.tests.utils import WagtailTestUtils

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

try:
from wagtail.test.utils import WagtailTestUtils
except ImportError:
from wagtail.tests.utils import WagtailTestUtils

from wagtail_ab_testing.models import AbTest
from wagtail_ab_testing.test.models import SimplePage
Expand Down
6 changes: 5 additions & 1 deletion wagtail_ab_testing/test/tests/test_serve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from django.test import TestCase, override_settings
from wagtail.core.models import Page

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

from wagtail_ab_testing.models import AbTest

Expand Down
6 changes: 5 additions & 1 deletion wagtail_ab_testing/test/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from django.urls import reverse
from freezegun import freeze_time
from rest_framework.test import APIClient, APITestCase
from wagtail.core.models import Page

try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

from wagtail_ab_testing.models import AbTest

Expand Down
20 changes: 12 additions & 8 deletions wagtail_ab_testing/test/urls.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from django.conf.urls import include, url
from django.urls import include, path
from django.contrib import admin

from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtail.core import urls as wagtail_urls

try:
from wagtail import urls as wagtail_urls
except ImportError:
from wagtail.core import urls as wagtail_urls

from wagtail_ab_testing import api as ab_testing_api
from wagtail_ab_testing import urls as ab_testing_urls


urlpatterns = [
url(r"^django-admin/", admin.site.urls),
url(r"^admin/", include(wagtailadmin_urls)),
url(r"^documents/", include(wagtaildocs_urls)),
url(r'^abtestingapi/', include(ab_testing_api, namespace='ab_testing_api')),
url(r'^abtesting/', include(ab_testing_urls, namespace='wagtail_ab_testing')),
path("django-admin/", admin.site.urls),
path("admin/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
path('abtestingapi/', include(ab_testing_api, namespace='ab_testing_api')),
path('abtesting/', include(ab_testing_urls, namespace='wagtail_ab_testing')),

url(r"", include(wagtail_urls)),
path("", include(wagtail_urls)),
]
7 changes: 5 additions & 2 deletions wagtail_ab_testing/test/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

from wagtail.core import hooks
try:
from wagtail import hooks
except ImportError:
from wagtail.core import hooks

from wagtail_ab_testing.events import BaseEvent


Expand Down
Loading