-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support wagtail42 #51
Conversation
and adjust the import paths to allow different wagtail versions
I removed the upper limits on wagtail and django versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Nick, there are a couple of mentions of wagtail 3 in Readme and setup to remove. They might have got merged in when you merged the other MRs. Also when testing locally, I got this error: ValueError: Related model 'wagtailcore.pagerevision' cannot be resolved
. Looks like one of the migration files needs updating.
README.md
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we dropping support for Wagtail < 4.1 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 391be2e
@@ -33,22 +33,25 @@ | |||
"Programming Language :: Python :: 3.7", | |||
"Programming Language :: Python :: 3.8", | |||
"Programming Language :: Python :: 3.9", | |||
"Programming Language :: Python :: 3.10", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Programming Language :: Python :: 3.11",
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 391be2e
setup.py
Outdated
"Framework :: Django", | ||
"Framework :: Django :: 2.2", | ||
"Framework :: Django :: 3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove support for Django 3.0 (for Wagtail 4.1 and above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 391be2e
setup.py
Outdated
"Framework :: Wagtail", | ||
"Framework :: Wagtail :: 2", | ||
"Framework :: Wagtail :: 3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're dropping support for Wagtail < 4.1? And need to add Wagtail 4.1 and 4.2.
Looks like something got confused here when merging in previous changes for Wagtail 4.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 391be2e
], | ||
install_requires=[ | ||
"Django>=2.2,<3.3", | ||
"Wagtail>=2.11,<2.17", | ||
"Wagtail>=4.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we limit to < 4.3
since we are not sure if it will be compatible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used wagtailmedia package as a guide for this
wa215: wagtail>=2.15rc1,<2.16 | ||
wa216: wagtail>=2.16.1,<2.17 | ||
wa41: wagtail>=4.1,<4.2 | ||
wa42: wagtail>=4.2,<5.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if we should make this more fine grain, e.g. wagtail>=4.2,<4.3
so if wagtail 4.3 comes out and is incompatible with the existing code here, the test will not suddenly fail before we can update this to be compatible with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 391be2e
wagtail_ab_testing/__init__.py
Outdated
default_app_config = "wagtail_ab_testing.apps.WagtailAbTestingAppConfig" | ||
from django import VERSION as DJANGO_VERSION | ||
|
||
if DJANGO_VERSION < (3, 2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wagtail 4.1 supports Django 3.2, 4.0, 4.1
only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 391be2e
wagtail_ab_testing/test/__init__.py
Outdated
@@ -1 +1,4 @@ | |||
default_app_config = "wagtail_ab_testing.test.apps.WagtailAbTestingTestAppConfig" | |||
from django import VERSION as DJANGO_VERSION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto above. Wagtail 4.1 supports Django 3.2, 4.0, 4.1
only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 391be2e
Wagtail 4.0 changes this model name, so we need to update the migration to use the new name.
Thanks this is now resolved in: 3c63ca4 |
"Framework :: Wagtail :: 2", | ||
"Framework :: Wagtail :: 3.0", | ||
"Framework :: Wagtail :: 4.0", | ||
"Framework :: Wagtail :: 4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't right either. I tend to follow the lead from wagtailmedia package
Thanks @victoriachan sorry for missing so much here. They should all be resolved now. |
@@ -77,7 +73,7 @@ class AbTest(models.Model): | |||
page = models.ForeignKey('wagtailcore.Page', on_delete=models.CASCADE, related_name='ab_tests') | |||
name = models.CharField(max_length=255) | |||
hypothesis = models.TextField(blank=True) | |||
variant_revision = models.ForeignKey(get_revision_model(), on_delete=models.CASCADE, related_name='+') | |||
variant_revision = models.ForeignKey('wagtailcore.Revision', on_delete=models.CASCADE, related_name='+') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there was more that could be done here + a new migration.
This should fix sites that have the package already installed but the treatment_revision
foreign key needs to be re-mapped as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having second thoughts about this change. It probably needs more work to update the variant_revision fields. Like rebuild_references_index
command in wagtail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you @nickmoreton that this is not enough to migrate to the Revision
model. I'm investigating the best way to go about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented a fix for this in #52 by squashing migrations. See the explanation in the PR description.
Thank you for this, @nickmoreton. Much appreciated, gonna give it a try! Do you actually work at Torchbox? I wonder, with all due respect to the repo's owner and their time, why wasn't this PR even considered for merging? Did they abandon the project? Best, |
i'm with @pymike00 on this one, would love to know if there's been any changes regarding the maintenance of this project. We're currently investigating options for adding A/B testing support to some wagtail projects, but the lack of support for newer WT versions is quite a deal breaker for us. Is this something either of you knows the answer to, @kaedroho or @victoriachan ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I can see quite the effort went into this. Thanks so much @nickmoreton ❤️
From a code-only perspective, almost all changes make sense to me... but I'm having difficulty testing this PR because I don't have an existing project (+ database) that uses this package to test this with. Because of this, I'm not going to approve this PR right now. Further (extensive) testing is required to make sure all works like expected.
Especially the migration from PageRevision
to Revision
is something that warrants further investigation to ensure it works for existing databases and new databases. Having an existing database to test with would be invaluable in testing.
I further suggest that we drop Python 3.7 support. Python 3.7 will be end-of-life next month.
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
## [Unreleased] | |||
|
|||
- Wagtail 4.2 compatibility | |||
- Old PR's for Wagtail 3.0 and Wagtail 4.0 are merged here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Old PR's for Wagtail 3.0 and Wagtail 4.0 are merged here |
Nitpick: this information is irrelevant for end-users (developers) using this package. The changelog should be kept concise.
@@ -18,6 +18,8 @@ Key features: | |||
|
|||
## Usage | |||
|
|||
Wagtail A/B Testing works with Django 3.2+, Wagtail 4.1+ on Python 3.7+ environments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wagtail A/B Testing works with Django 3.2+, Wagtail 4.1+ on Python 3.7+ environments. | |
Wagtail A/B Testing works with Django 3.2+, Wagtail 4.1+ on Python 3.8+ environments. |
Suggestion: let's drop official 3.7 support. Python 3.7 is almost 5 years old and will stop receiving updates next month (source)
@@ -33,22 +33,23 @@ | |||
"Programming Language :: Python :: 3.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Programming Language :: Python :: 3.7", |
(see above comment about dropping 3.7 support)
@@ -2,7 +2,9 @@ | |||
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,310}-dj{32,40,41}-wa{41,42}-{sqlite,postgres} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
py{37,38,39,310}-dj{32,40,41}-wa{41,42}-{sqlite,postgres} | |
py{38,39,310}-dj{32,40,41}-wa{41,42}-{sqlite,postgres} |
(see comment about dropping Python 3.7 support)
@@ -17,21 +19,23 @@ commands = coverage run testmanage.py test --deprecation all | |||
basepython = | |||
py37: python3.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
py37: python3.7 |
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')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: there is some inconsistent quoting here. Would be great if we could adopt a formatter like Black to enforce consistency.
This also what we should be doing according to the Python Package Maintenance guidelines (Continuous Integration section).
Not blocking, but something to consider to further improve this package in the future 🙂
|
||
from wagtail.core import hooks | ||
from wagtail import hooks | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -77,7 +73,7 @@ class AbTest(models.Model): | |||
page = models.ForeignKey('wagtailcore.Page', on_delete=models.CASCADE, related_name='ab_tests') | |||
name = models.CharField(max_length=255) | |||
hypothesis = models.TextField(blank=True) | |||
variant_revision = models.ForeignKey(get_revision_model(), on_delete=models.CASCADE, related_name='+') | |||
variant_revision = models.ForeignKey('wagtailcore.Revision', on_delete=models.CASCADE, related_name='+') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you @nickmoreton that this is not enough to migrate to the Revision
model. I'm investigating the best way to go about this.
We are thrilled about incorporating the wagtail-ab-testing package into our project. However, since it doesn't currently support version 4.2, we are unable to use it. We appreciate the effort you have put into adding support for the 4.2 version. We hope that this pull request gets merged swiftly, and we eagerly await its integration. Thank you to @nickmoreton, @Stormheg and @victoriachan for your contributions. |
Hey all, I've spent a couple more hours on this and have come up with a revised PR (#52) that includes a fix for the PageRevision to Revision migration. This fix should work for new projects and projects already wagtail ab testing. I don't think there are any other obstacles that prevent supporting Wagtail 4.1 and 4.2, hope my PR is merged soon 🤞 |
superseded by #52 |
This updates the package for Wagtail 4.2
Drops: support for Wagtail < 4.1
For completeness I have merged in the following previous work: