From 2f7b92fb2e730d96edc5948273ae7ac61fab16c1 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Tue, 18 Dec 2018 10:40:45 +0200 Subject: [PATCH 01/28] Run tests on python 3.6 --- .travis.yml | 8 ++++---- tox.ini | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a78086..ca57aa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,11 @@ language: python matrix: include: - - python: 2.7 + - python: 3.6 env: lint - - python: 2.7 - env: TOXENV=py27-django111-wagtail113 + - python: 3.6 + env: TOXENV=py36-django111-wagtail113 install: - pip install tox codecov @@ -28,4 +28,4 @@ deploy: secure: IxPnc95OFNQsl7kFfLlLc38KfHh/W79VXnhEkdb2x1GZznOsG167QlhpAnyXIJysCQxgMMwLMuPOOdk1WIxOpGNM1/M80hNzPAfxMYWPuwposDdwoIc8SyREPJt16BXWAY+rAH8SHxld9p1YdRbOEPSSglODe4dCmQWsCbKjV3aKv+gZxBvf6pMxUglp2fBIlCwrE77MyMYh9iW0AGzD6atC2xN9NgAm4f+2WFlKCUL/MztLhNWdvWEiibQav6Tts7p8tWrsBVzywDW2IOy3O0ihPgRdISZ7QrxhiJTjlHYPAy4eRGOnYSQXvp6Dy8ONE5a6Uv5g3Xw2UmQo85sSMUs2VxR0G7d+PQgL0A7ENBQ5i7eSAFHYs8EswiGilW2A7mM4qRXwg9URLelYSdkM+aNXvR+25dCsXakiO4NjCz/BPgNzxPeQLlBdxR5vHugeM/XYuhy6CHlZrR/uueaO0X8RyhJcqeDjBy58IrwYS3Mpj7QCfBpQ9PqsqXEWV9BKwKiBXM2+3hkhawFDWa0GW2PDbORKtSLy/ORfGLx5Y9qxQYKEGvFQA3iqkTjrLj+KeUziKtuvEAcvsdBIJVIxeoHwdl+qqxEm8A7YuRBnWVxWc3jE6wBXboeFP92gVe/ueoXmY22riK9Ja0pli3TyNga8by9WM8Qp4D2ZqkVXHwg= on: tags: true - condition: $TOXENV = py27-django111-wagtail113 + condition: $TOXENV = py36-django111-wagtail113 diff --git a/tox.ini b/tox.ini index 34be95a..3ebbb43 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{27}-django{111}-wagtail{113},lint +envlist = py{36}-django{111}-wagtail{113},lint [testenv] commands = coverage run --parallel -m pytest {posargs} @@ -9,7 +9,7 @@ deps = wagtail19: wagtail>=1.13,<1.14 [testenv:coverage-report] -basepython = python2.7 +basepython = python3.6 deps = coverage pip_pre = true skip_install = true @@ -19,7 +19,7 @@ commands = [testenv:lint] -basepython = python2.7 +basepython = python3.6 deps = flake8==3.5.0 commands = flake8 src tests setup.py From 9c45ac56db70ff1f9d3b0abd616499cf09886f7b Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Tue, 18 Dec 2018 13:30:27 +0200 Subject: [PATCH 02/28] Upgrade Wagtail to 2.0 in requirements and tests --- setup.py | 6 +++--- tox.ini | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 15b216b..6411fd3 100644 --- a/setup.py +++ b/setup.py @@ -2,9 +2,9 @@ import re from setuptools import find_packages, setup install_requires = [ - 'wagtail>=1.10,<1.14', + 'wagtail>=2.0,<2.1', 'user-agents>=1.0.1', - 'wagtailfontawesome>=1.0.6', + 'wagtailfontawesome>=1.1.3', ] tests_require = [ @@ -19,7 +19,7 @@ tests_require = [ 'pytest-sugar==0.7.1', 'pytest-mock==1.6.3', 'pytest==3.1.0', - 'wagtail_factories==0.3.0', + 'wagtail_factories==1.1.0', ] docs_require = [ diff --git a/tox.ini b/tox.ini index 3ebbb43..e6b8243 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] -envlist = py{36}-django{111}-wagtail{113},lint +envlist = py{36}-django{111}-wagtail{20},lint [testenv] commands = coverage run --parallel -m pytest {posargs} extras = test deps = django111: django>=1.11,<1.12 - wagtail19: wagtail>=1.13,<1.14 + wagtail19: wagtail>=2.0,<2.1 [testenv:coverage-report] basepython = python3.6 From 1c74e6cfb96556574b3746e7804dd3fdcd40d6ee Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Tue, 18 Dec 2018 13:32:02 +0200 Subject: [PATCH 03/28] Update Wagtail imports to work for 2.0 --- .../migrations/0003_homepage_text_content.py | 6 ++--- sandbox/sandbox/apps/home/models.py | 8 +++--- sandbox/sandbox/apps/search/views.py | 4 +-- sandbox/sandbox/settings.py | 26 +++++++++---------- sandbox/sandbox/urls.py | 6 ++--- src/wagtail_personalisation/blocks.py | 2 +- src/wagtail_personalisation/forms.py | 2 +- src/wagtail_personalisation/models.py | 4 +-- src/wagtail_personalisation/rules.py | 2 +- src/wagtail_personalisation/views.py | 2 +- src/wagtail_personalisation/wagtail_hooks.py | 16 ++++++------ tests/conftest.py | 2 +- tests/factories/site.py | 2 +- tests/settings.py | 16 ++++++------ tests/site/pages/migrations/0001_initial.py | 4 +-- .../site/pages/migrations/0002_regularpage.py | 4 +-- tests/site/pages/models.py | 6 ++--- tests/site/urls.py | 6 ++--- 18 files changed, 59 insertions(+), 59 deletions(-) diff --git a/sandbox/sandbox/apps/home/migrations/0003_homepage_text_content.py b/sandbox/sandbox/apps/home/migrations/0003_homepage_text_content.py index d4108b9..adb5502 100644 --- a/sandbox/sandbox/apps/home/migrations/0003_homepage_text_content.py +++ b/sandbox/sandbox/apps/home/migrations/0003_homepage_text_content.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals from django.db import migrations -import wagtail.wagtailcore.fields +import wagtail.core.fields import wagtail_personalisation @@ -17,14 +17,14 @@ class Migration(migrations.Migration): migrations.AddField( model_name='homepage', name='intro', - field=wagtail.wagtailcore.fields.RichTextField( + field=wagtail.core.fields.RichTextField( default='

Thank you for trying Wagxperience!

'), preserve_default=False, ), migrations.AddField( model_name='homepage', name='body', - field=wagtail.wagtailcore.fields.StreamField((('personalisable_paragraph', wagtail.wagtailcore.blocks.StructBlock((('segment', wagtail.wagtailcore.blocks.ChoiceBlock(choices=wagtail_personalisation.blocks.list_segment_choices, help_text='Only show this content block for users in this segment', label='Personalisation segment', required=False)), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock())), icon='pilcrow')),), default=''), + field=wagtail.core.fields.StreamField((('personalisable_paragraph', wagtail.core.blocks.StructBlock((('segment', wagtail.core.blocks.ChoiceBlock(choices=wagtail_personalisation.blocks.list_segment_choices, help_text='Only show this content block for users in this segment', label='Personalisation segment', required=False)), ('paragraph', wagtail.core.blocks.RichTextBlock())), icon='pilcrow')),), default=''), preserve_default=False, ), ] diff --git a/sandbox/sandbox/apps/home/models.py b/sandbox/sandbox/apps/home/models.py index 0d409fe..fbd05b0 100644 --- a/sandbox/sandbox/apps/home/models.py +++ b/sandbox/sandbox/apps/home/models.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, unicode_literals -from wagtail.wagtailadmin.edit_handlers import RichTextFieldPanel, StreamFieldPanel -from wagtail.wagtailcore import blocks -from wagtail.wagtailcore.fields import RichTextField, StreamField -from wagtail.wagtailcore.models import Page +from wagtail.admin.edit_handlers import RichTextFieldPanel, StreamFieldPanel +from wagtail.core import blocks +from wagtail.core.fields import RichTextField, StreamField +from wagtail.core.models import Page from wagtail_personalisation.models import PersonalisablePageMixin from wagtail_personalisation.blocks import PersonalisedStructBlock diff --git a/sandbox/sandbox/apps/search/views.py b/sandbox/sandbox/apps/search/views.py index e17a1e9..78b1631 100644 --- a/sandbox/sandbox/apps/search/views.py +++ b/sandbox/sandbox/apps/search/views.py @@ -3,8 +3,8 @@ from __future__ import absolute_import, unicode_literals from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.shortcuts import render -from wagtail.wagtailcore.models import Page -from wagtail.wagtailsearch.models import Query +from wagtail.core.models import Page +from wagtail.search.models import Query def search(request): diff --git a/sandbox/sandbox/settings.py b/sandbox/sandbox/settings.py index ac25145..daebf13 100644 --- a/sandbox/sandbox/settings.py +++ b/sandbox/sandbox/settings.py @@ -33,17 +33,17 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Application definition INSTALLED_APPS = [ - 'wagtail.wagtailforms', - 'wagtail.wagtailredirects', - 'wagtail.wagtailembeds', - 'wagtail.wagtailsites', - 'wagtail.wagtailusers', - 'wagtail.wagtailsnippets', - 'wagtail.wagtaildocs', - 'wagtail.wagtailimages', - 'wagtail.wagtailsearch', - 'wagtail.wagtailadmin', - 'wagtail.wagtailcore', + 'wagtail.contrib.forms', + 'wagtail.contrib.redirects', + 'wagtail.embeds', + 'wagtail.sites', + 'wagtail.users', + 'wagtail.snippets', + 'wagtail.documents', + 'wagtail.images', + 'wagtail.search', + 'wagtail.admin', + 'wagtail.core', 'wagtail.contrib.modeladmin', 'wagtailfontawesome', @@ -77,8 +77,8 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', - 'wagtail.wagtailcore.middleware.SiteMiddleware', - 'wagtail.wagtailredirects.middleware.RedirectMiddleware', + 'wagtail.core.middleware.SiteMiddleware', + 'wagtail.contrib.redirects.middleware.RedirectMiddleware', ] ROOT_URLCONF = 'sandbox.urls' diff --git a/sandbox/sandbox/urls.py b/sandbox/sandbox/urls.py index 383a8e6..c63a67b 100644 --- a/sandbox/sandbox/urls.py +++ b/sandbox/sandbox/urls.py @@ -4,9 +4,9 @@ import debug_toolbar from django.conf import settings from django.conf.urls import include, url from django.contrib import admin -from wagtail.wagtailadmin import urls as wagtailadmin_urls -from wagtail.wagtailcore import urls as wagtail_urls -from wagtail.wagtaildocs import urls as wagtaildocs_urls +from wagtail.admin import urls as wagtailadmin_urls +from wagtail.core import urls as wagtail_urls +from wagtail.documents import urls as wagtaildocs_urls from sandbox.apps.search import views as search_views diff --git a/src/wagtail_personalisation/blocks.py b/src/wagtail_personalisation/blocks.py index fd6d35d..3d74f93 100644 --- a/src/wagtail_personalisation/blocks.py +++ b/src/wagtail_personalisation/blocks.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ -from wagtail.wagtailcore import blocks +from wagtail.core import blocks from wagtail_personalisation.adapters import get_segment_adapter from wagtail_personalisation.models import Segment diff --git a/src/wagtail_personalisation/forms.py b/src/wagtail_personalisation/forms.py index 02555eb..c0fbc08 100644 --- a/src/wagtail_personalisation/forms.py +++ b/src/wagtail_personalisation/forms.py @@ -10,7 +10,7 @@ from django.contrib.staticfiles.templatetags.staticfiles import static from django.test.client import RequestFactory from django.utils.lru_cache import lru_cache from django.utils.translation import ugettext_lazy as _ -from wagtail.wagtailadmin.forms import WagtailAdminModelForm +from wagtail.admin.forms import WagtailAdminModelForm SessionStore = import_module(settings.SESSION_ENGINE).SessionStore diff --git a/src/wagtail_personalisation/models.py b/src/wagtail_personalisation/models.py index 7a4063e..ae3ed4e 100644 --- a/src/wagtail_personalisation/models.py +++ b/src/wagtail_personalisation/models.py @@ -11,9 +11,9 @@ from django.utils.functional import cached_property from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from modelcluster.models import ClusterableModel -from wagtail.wagtailadmin.edit_handlers import ( +from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel) -from wagtail.wagtailcore.models import Page +from wagtail.core.models import Page from wagtail_personalisation.rules import AbstractBaseRule from wagtail_personalisation.utils import count_active_days diff --git a/src/wagtail_personalisation/rules.py b/src/wagtail_personalisation/rules.py index 4fa82f7..c012cd0 100644 --- a/src/wagtail_personalisation/rules.py +++ b/src/wagtail_personalisation/rules.py @@ -15,7 +15,7 @@ from django.utils.translation import ugettext_lazy as _ from django.test.client import RequestFactory from modelcluster.fields import ParentalKey from user_agents import parse -from wagtail.wagtailadmin.edit_handlers import ( +from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, PageChooserPanel) SessionStore = import_module(settings.SESSION_ENGINE).SessionStore diff --git a/src/wagtail_personalisation/views.py b/src/wagtail_personalisation/views.py index 8227367..1a53591 100644 --- a/src/wagtail_personalisation/views.py +++ b/src/wagtail_personalisation/views.py @@ -8,7 +8,7 @@ from django.shortcuts import get_object_or_404 from django.utils.translation import ugettext_lazy as _ from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register from wagtail.contrib.modeladmin.views import IndexView -from wagtail.wagtailcore.models import Page +from wagtail.core.models import Page from wagtail_personalisation.models import Segment diff --git a/src/wagtail_personalisation/wagtail_hooks.py b/src/wagtail_personalisation/wagtail_hooks.py index 4f5a31d..6c91c99 100644 --- a/src/wagtail_personalisation/wagtail_hooks.py +++ b/src/wagtail_personalisation/wagtail_hooks.py @@ -7,10 +7,10 @@ from django.core.urlresolvers import reverse from django.template.defaultfilters import pluralize from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ -from wagtail.wagtailadmin.site_summary import PagesSummaryItem, SummaryItem -from wagtail.wagtailadmin.widgets import Button, ButtonWithDropdownFromHook -from wagtail.wagtailcore import hooks -from wagtail.wagtailcore.models import Page +from wagtail.admin.site_summary import PagesSummaryItem, SummaryItem +from wagtail.admin.widgets import Button, ButtonWithDropdownFromHook +from wagtail.core import hooks +from wagtail.core.models import Page from wagtail_personalisation import admin_urls, models, utils from wagtail_personalisation.adapters import get_segment_adapter @@ -35,7 +35,7 @@ def set_visit_count(page, request, serve_args, serve_kwargs): to a segment. :param page: The page being served - :type page: wagtail.wagtailcore.models.Page + :type page: wagtail.core.models.Page :param request: The http request :type request: django.http.HttpRequest @@ -49,7 +49,7 @@ def segment_user(page, request, serve_args, serve_kwargs): """Apply a segment to a visitor before serving the page. :param page: The page being served - :type page: wagtail.wagtailcore.models.Page + :type page: wagtail.core.models.Page :param request: The http request :type request: django.http.HttpRequest @@ -63,12 +63,12 @@ def serve_variant(page, request, serve_args, serve_kwargs): """Apply a segment to a visitor before serving the page. :param page: The page being served - :type page: wagtail.wagtailcore.models.Page + :type page: wagtail.core.models.Page :param request: The http request :type request: django.http.HttpRequest :returns: A variant if one is available for the visitor's segment, otherwise the original page - :rtype: wagtail.wagtailcore.models.Page + :rtype: wagtail.core.models.Page """ user_segments = [] diff --git a/tests/conftest.py b/tests/conftest.py index ee60a76..77e07e7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,7 @@ pytest_plugins = [ @pytest.fixture(scope='session') def django_db_setup(django_db_setup, django_db_blocker): - from wagtail.wagtailcore.models import Page, Site + from wagtail.core.models import Page, Site with django_db_blocker.unblock(): # Remove some initial data that is brought by the tests.site module diff --git a/tests/factories/site.py b/tests/factories/site.py index cf8f65a..631963b 100644 --- a/tests/factories/site.py +++ b/tests/factories/site.py @@ -1,5 +1,5 @@ import factory -from wagtail.wagtailcore.models import Site +from wagtail.core.models import Site from tests.factories.page import ContentPageFactory diff --git a/tests/settings.py b/tests/settings.py index ac0f1c0..e2f174e 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -66,7 +66,7 @@ def get_middleware_settings(): 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'wagtail.wagtailcore.middleware.SiteMiddleware', + 'wagtail.core.middleware.SiteMiddleware', ) @@ -80,13 +80,13 @@ INSTALLED_APPS = ( 'wagtail_personalisation', 'wagtail.contrib.modeladmin', - 'wagtail.wagtailsearch', - 'wagtail.wagtailsites', - 'wagtail.wagtailusers', - 'wagtail.wagtailimages', - 'wagtail.wagtaildocs', - 'wagtail.wagtailadmin', - 'wagtail.wagtailcore', + 'wagtail.search', + 'wagtail.sites', + 'wagtail.users', + 'wagtail.images', + 'wagtail.documents', + 'wagtail.admin', + 'wagtail.core', 'taggit', diff --git a/tests/site/pages/migrations/0001_initial.py b/tests/site/pages/migrations/0001_initial.py index b24911e..bbd7542 100644 --- a/tests/site/pages/migrations/0001_initial.py +++ b/tests/site/pages/migrations/0001_initial.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import django.db.models.deletion -import wagtail.wagtailcore.fields +import wagtail.core.fields from django.db import migrations, models import wagtail_personalisation.models @@ -23,7 +23,7 @@ class Migration(migrations.Migration): fields=[ ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), # noqa: E501 ('subtitle', models.CharField(blank=True, default='', max_length=255)), - ('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')), + ('body', wagtail.core.fields.RichTextField(blank=True, default='')), ], options={ 'abstract': False, diff --git a/tests/site/pages/migrations/0002_regularpage.py b/tests/site/pages/migrations/0002_regularpage.py index 09be0f8..d196a05 100644 --- a/tests/site/pages/migrations/0002_regularpage.py +++ b/tests/site/pages/migrations/0002_regularpage.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import django.db.models.deletion -import wagtail.wagtailcore.fields +import wagtail.core.fields from django.db import migrations, models @@ -20,7 +20,7 @@ class Migration(migrations.Migration): fields=[ ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), # noqa: E501 ('subtitle', models.CharField(blank=True, default='', max_length=255)), - ('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')), + ('body', wagtail.core.fields.RichTextField(blank=True, default='')), ], options={ 'abstract': False, diff --git a/tests/site/pages/models.py b/tests/site/pages/models.py index 1ee6603..28f1702 100644 --- a/tests/site/pages/models.py +++ b/tests/site/pages/models.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, unicode_literals from django.db import models -from wagtail.wagtailadmin.edit_handlers import FieldPanel -from wagtail.wagtailcore.fields import RichTextField -from wagtail.wagtailcore.models import Page +from wagtail.admin.edit_handlers import FieldPanel +from wagtail.core.fields import RichTextField +from wagtail.core.models import Page from wagtail_personalisation.models import PersonalisablePageMixin diff --git a/tests/site/urls.py b/tests/site/urls.py index cb109ba..a47bb5a 100644 --- a/tests/site/urls.py +++ b/tests/site/urls.py @@ -2,9 +2,9 @@ from __future__ import absolute_import, unicode_literals from django.conf.urls import include, url from django.contrib import admin -from wagtail.wagtailadmin import urls as wagtailadmin_urls -from wagtail.wagtailcore import urls as wagtail_urls -from wagtail.wagtaildocs import urls as wagtaildocs_urls +from wagtail.admin import urls as wagtailadmin_urls +from wagtail.core import urls as wagtail_urls +from wagtail.documents import urls as wagtaildocs_urls urlpatterns = [ url(r'^django-admin/', include(admin.site.urls)), From 0f9bfb0343ec0b1d9b56b028563deb68319faeb0 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Tue, 18 Dec 2018 13:37:34 +0200 Subject: [PATCH 04/28] Tell travis to use Wagtail 2.0 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ca57aa7..7480ece 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: env: lint - python: 3.6 - env: TOXENV=py36-django111-wagtail113 + env: TOXENV=py36-django111-wagtail20 install: - pip install tox codecov @@ -28,4 +28,4 @@ deploy: secure: IxPnc95OFNQsl7kFfLlLc38KfHh/W79VXnhEkdb2x1GZznOsG167QlhpAnyXIJysCQxgMMwLMuPOOdk1WIxOpGNM1/M80hNzPAfxMYWPuwposDdwoIc8SyREPJt16BXWAY+rAH8SHxld9p1YdRbOEPSSglODe4dCmQWsCbKjV3aKv+gZxBvf6pMxUglp2fBIlCwrE77MyMYh9iW0AGzD6atC2xN9NgAm4f+2WFlKCUL/MztLhNWdvWEiibQav6Tts7p8tWrsBVzywDW2IOy3O0ihPgRdISZ7QrxhiJTjlHYPAy4eRGOnYSQXvp6Dy8ONE5a6Uv5g3Xw2UmQo85sSMUs2VxR0G7d+PQgL0A7ENBQ5i7eSAFHYs8EswiGilW2A7mM4qRXwg9URLelYSdkM+aNXvR+25dCsXakiO4NjCz/BPgNzxPeQLlBdxR5vHugeM/XYuhy6CHlZrR/uueaO0X8RyhJcqeDjBy58IrwYS3Mpj7QCfBpQ9PqsqXEWV9BKwKiBXM2+3hkhawFDWa0GW2PDbORKtSLy/ORfGLx5Y9qxQYKEGvFQA3iqkTjrLj+KeUziKtuvEAcvsdBIJVIxeoHwdl+qqxEm8A7YuRBnWVxWc3jE6wBXboeFP92gVe/ueoXmY22riK9Ja0pli3TyNga8by9WM8Qp4D2ZqkVXHwg= on: tags: true - condition: $TOXENV = py36-django111-wagtail113 + condition: $TOXENV = py36-django111-wagtail20 From dcdeb4e9a29e3f12feb868b70656efd643cad078 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Tue, 18 Dec 2018 14:02:01 +0200 Subject: [PATCH 05/28] Update imports in examples in docs --- docs/implementation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/implementation.rst b/docs/implementation.rst index 93b3208..7ddd568 100644 --- a/docs/implementation.rst +++ b/docs/implementation.rst @@ -37,7 +37,7 @@ Rules consist of two important elements, the model's fields and the ``test_user` A very simple example of a rule would look something like this:: from django.db import models - from wagtail.wagtailadmin.edit_handlers import FieldPanel + from wagtail.admin.edit_handlers import FieldPanel from personalisation import AbstractBaseRule class MyNewRule(AbstractBaseRule): From 83cc7f790e25aa3dfcc3e98de11eea910fa31382 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Tue, 18 Dec 2018 14:03:01 +0200 Subject: [PATCH 06/28] Bump version to 1.0.0 --- CHANGES | 6 ++++++ docs/conf.py | 4 ++-- setup.cfg | 2 +- setup.py | 6 ++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index a5f1c2b..859bea8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +1.0.0 +================== + - Upgrade to Python 3.6, drop support for Python 2.7 + - Upgrade to Wagtail 2.0, drop support for Wagtail < 2 + - These are breaking changes for dependant projects that explicitly import Wagtail modules + 0.11.3 ================== - Bugfix: Handle errors when testing an invalid visit count rule diff --git a/docs/conf.py b/docs/conf.py index 1a7483a..a8ffa49 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,10 +55,10 @@ author = 'Lab Digital BV' # built documents. # # The short X.Y version. -version = '0.11.3' +version = '1.0.0' # The full version, including alpha/beta/rc tags. -release = '0.11.3' +release = '1.0.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.cfg b/setup.cfg index 5faf6ce..c363f93 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.11.3 +current_version = 1.0.0 commit = true tag = true tag_name = {new_version} diff --git a/setup.py b/setup.py index 6411fd3..8cba5b9 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ with open('README.rst') as fh: setup( name='wagtail-personalisation-molo', - version='0.11.3', + version='1.0.0', description='A forked version of Wagtail add-on for showing personalized content', author='Praekelt.org', author_email='dev@praekeltfoundation.org', @@ -49,13 +49,11 @@ setup( license='MIT', long_description=long_description, classifiers=[ - 'Development Status :: 2 - Pre-Alpha', + 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', From d3f4d42d82a061b98c7da6ac5895563fcf97625e Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Wed, 2 Jan 2019 16:51:56 +0200 Subject: [PATCH 07/28] Define panel for rules to handle InlinePanel changes --- src/wagtail_personalisation/models.py | 10 +++++++++- tests/unit/test_models.py | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wagtail_personalisation/models.py b/src/wagtail_personalisation/models.py index ae3ed4e..92fa233 100644 --- a/src/wagtail_personalisation/models.py +++ b/src/wagtail_personalisation/models.py @@ -21,6 +21,14 @@ from wagtail_personalisation.utils import count_active_days from .forms import SegmentAdminForm +class RulePanel(InlinePanel): + def on_model_bound(self): + self.db_field = self.model._meta.get_field( + self.relation_name.replace('_related', 's')) + manager = getattr(self.model, self.relation_name) + self.related = manager.rel + + class SegmentQuerySet(models.QuerySet): def enabled(self): return self.filter(status=self.model.STATUS_ENABLED) @@ -121,7 +129,7 @@ class Segment(ClusterableModel): FieldPanel('randomisation_percent', classname='percent_field'), ], heading="Segment"), MultiFieldPanel([ - InlinePanel( + RulePanel( "{}_related".format(rule_model._meta.db_table), label='{}{}'.format( rule_model._meta.verbose_name, diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py index 078240b..7ee7294 100644 --- a/tests/unit/test_models.py +++ b/tests/unit/test_models.py @@ -6,6 +6,7 @@ import pytest from tests.factories.segment import SegmentFactory from wagtail_personalisation.rules import TimeRule +from wagtail_personalisation.models import Segment @pytest.mark.django_db @@ -25,3 +26,10 @@ def test_metadata_page_has_variants(segmented_page): canonical = segmented_page.personalisation_metadata.canonical_page assert canonical.personalisation_metadata.is_canonical assert canonical.personalisation_metadata.has_variants + + +@pytest.mark.django_db +def test_segment_edit_view(site, client, django_user_model): + test_segment = Segment() + new_panel = test_segment.panels[1].children[0].bind_to_model(Segment) + assert new_panel.related.name == "wagtail_personalisation_timerules" From 1a1df18bf31dd5e4ce57c73f04489c24126e0e21 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Wed, 2 Jan 2019 17:28:36 +0200 Subject: [PATCH 08/28] Bump version to 1.0.1 --- CHANGES | 4 ++++ docs/conf.py | 4 ++-- setup.cfg | 2 +- setup.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 859bea8..1c93f5b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1.0.1 +================== + - Added RulePanel, a subclass of InlinePanel, for Rules + 1.0.0 ================== - Upgrade to Python 3.6, drop support for Python 2.7 diff --git a/docs/conf.py b/docs/conf.py index a8ffa49..4ffa1ce 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,10 +55,10 @@ author = 'Lab Digital BV' # built documents. # # The short X.Y version. -version = '1.0.0' +version = '1.0.1' # The full version, including alpha/beta/rc tags. -release = '1.0.0' +release = '1.0.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.cfg b/setup.cfg index c363f93..bb5813c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.0 +current_version = 1.0.1 commit = true tag = true tag_name = {new_version} diff --git a/setup.py b/setup.py index 8cba5b9..0530191 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ with open('README.rst') as fh: setup( name='wagtail-personalisation-molo', - version='1.0.0', + version='1.0.1', description='A forked version of Wagtail add-on for showing personalized content', author='Praekelt.org', author_email='dev@praekeltfoundation.org', From 7888f0b6153d7cb4a21f09a2eb10b8c97111084e Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Wed, 9 Jan 2019 16:12:05 +0200 Subject: [PATCH 09/28] Upgrade to wagtail 2.2 in requirements and tests --- setup.py | 2 +- tox.ini | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 0530191..d2667ad 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import re from setuptools import find_packages, setup install_requires = [ - 'wagtail>=2.0,<2.1', + 'wagtail>=2.2,<2.3', 'user-agents>=1.0.1', 'wagtailfontawesome>=1.1.3', ] diff --git a/tox.ini b/tox.ini index e6b8243..eca2662 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] -envlist = py{36}-django{111}-wagtail{20},lint +envlist = py{36}-django{111}-wagtail{22},lint [testenv] commands = coverage run --parallel -m pytest {posargs} extras = test deps = django111: django>=1.11,<1.12 - wagtail19: wagtail>=2.0,<2.1 + wagtail19: wagtail>=2.2,<2.3 [testenv:coverage-report] basepython = python3.6 From 0d260a12a40afae966575ff2b1d7e8bf1e157e04 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Wed, 9 Jan 2019 16:28:31 +0200 Subject: [PATCH 10/28] Tell travis to use wagtail 2.2 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7480ece..3a888ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: env: lint - python: 3.6 - env: TOXENV=py36-django111-wagtail20 + env: TOXENV=py36-django111-wagtail22 install: - pip install tox codecov @@ -28,4 +28,4 @@ deploy: secure: IxPnc95OFNQsl7kFfLlLc38KfHh/W79VXnhEkdb2x1GZznOsG167QlhpAnyXIJysCQxgMMwLMuPOOdk1WIxOpGNM1/M80hNzPAfxMYWPuwposDdwoIc8SyREPJt16BXWAY+rAH8SHxld9p1YdRbOEPSSglODe4dCmQWsCbKjV3aKv+gZxBvf6pMxUglp2fBIlCwrE77MyMYh9iW0AGzD6atC2xN9NgAm4f+2WFlKCUL/MztLhNWdvWEiibQav6Tts7p8tWrsBVzywDW2IOy3O0ihPgRdISZ7QrxhiJTjlHYPAy4eRGOnYSQXvp6Dy8ONE5a6Uv5g3Xw2UmQo85sSMUs2VxR0G7d+PQgL0A7ENBQ5i7eSAFHYs8EswiGilW2A7mM4qRXwg9URLelYSdkM+aNXvR+25dCsXakiO4NjCz/BPgNzxPeQLlBdxR5vHugeM/XYuhy6CHlZrR/uueaO0X8RyhJcqeDjBy58IrwYS3Mpj7QCfBpQ9PqsqXEWV9BKwKiBXM2+3hkhawFDWa0GW2PDbORKtSLy/ORfGLx5Y9qxQYKEGvFQA3iqkTjrLj+KeUziKtuvEAcvsdBIJVIxeoHwdl+qqxEm8A7YuRBnWVxWc3jE6wBXboeFP92gVe/ueoXmY22riK9Ja0pli3TyNga8by9WM8Qp4D2ZqkVXHwg= on: tags: true - condition: $TOXENV = py36-django111-wagtail20 + condition: $TOXENV = py36-django111-wagtail22 From 4c09ad4ca7721d38ecb6edab8a19f51673f2c1fa Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 16:52:26 +0200 Subject: [PATCH 11/28] fix flake error W504 --- src/wagtail_personalisation/adapters.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wagtail_personalisation/adapters.py b/src/wagtail_personalisation/adapters.py index 7c84f42..ad2971e 100644 --- a/src/wagtail_personalisation/adapters.py +++ b/src/wagtail_personalisation/adapters.py @@ -186,8 +186,7 @@ class SessionSegmentsAdapter(BaseSegmentsAdapter): for segment in enabled_segments: if segment.is_static and segment.static_users.filter(id=self.request.user.id).exists(): additional_segments.append(segment) - elif (segment.excluded_users.filter(id=self.request.user.id).exists() or - segment in excluded_segments): + elif (segment.excluded_users.filter(id=self.request.user.id).exists() or segment in excluded_segments): continue elif not segment.is_static or not segment.is_full: segment_rules = [] From 875d8302deb220c188ba7608f4dcfa758137ccbd Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 16:54:04 +0200 Subject: [PATCH 12/28] exclude variants should return a list when a list if given or a queryset --- src/wagtail_personalisation/utils.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/wagtail_personalisation/utils.py b/src/wagtail_personalisation/utils.py index 49bea40..bdc3c31 100644 --- a/src/wagtail_personalisation/utils.py +++ b/src/wagtail_personalisation/utils.py @@ -103,17 +103,13 @@ def exclude_variants(pages): :return: List of pages that aren't variants :rtype: list """ - return [ - page for page in pages - if ( - ( - hasattr(page, 'personalisation_metadata') is False - ) or - ( - hasattr(page, 'personalisation_metadata') and page.personalisation_metadata is None - ) or - ( - hasattr(page, 'personalisation_metadata') and page.personalisation_metadata.is_canonical - ) - ) - ] + + for page in pages: + if not ((hasattr(page, 'personalisation_metadata') is False + ) or (hasattr(page, 'personalisation_metadata') and page.personalisation_metadata is None + ) or (hasattr(page, 'personalisation_metadata') and page.personalisation_metadata.is_canonical)): + if (type(pages) == list): + pages.remove(page) + else: + pages.exclude(pk=page.pk) + return pages From 94a5c6b289fc179ada8100d68813a55d40327eaf Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 16:54:28 +0200 Subject: [PATCH 13/28] tests for querysets in variant_exclude --- tests/unit/test_utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index f5cee8a..c5f4af5 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,6 +1,8 @@ from wagtail_personalisation.utils import ( exclude_variants, impersonate_other_page) +from wagtail.core.models import Page as WagtailPage + class Page(object): def __init__(self, path, depth, url_path, title): @@ -57,3 +59,15 @@ def test_exclude_variants_excludes_pages_with_metadata_not_canonical(): page.personalisation_metadata.is_canonical = False result = exclude_variants([page]) assert result == [] + + +def test_exclude_variants_with_pages_querysets(): + ''' + Test that excludes variant works for querysets too + ''' + page1 = WagtailPage(path="/", depth=0, url_path="/", title="Hoi") + page2 = WagtailPage(path="/", depth=0, url_path="/", title="Hoi") + pages = WagtailPage.objects.all().order_by('id') + print(pages) + result = exclude_variants(pages) + assert result == pages From 28266c450080a91a85bc1caacdc3ce011d9b7761 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 16:54:49 +0200 Subject: [PATCH 14/28] fix flake error --- src/wagtail_personalisation/wagtail_hooks.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wagtail_personalisation/wagtail_hooks.py b/src/wagtail_personalisation/wagtail_hooks.py index 6c91c99..b7e1ff3 100644 --- a/src/wagtail_personalisation/wagtail_hooks.py +++ b/src/wagtail_personalisation/wagtail_hooks.py @@ -185,8 +185,7 @@ class PersonalisedPagesSummaryPanel(PagesSummaryItem): order = 2100 def render(self): - page_count = models.PersonalisablePageMetadata.objects.filter( - segment__isnull=True).count() + page_count = models.PersonalisablePageMetadata.objects.filter(segment__isnull=True).count() title = _("Personalised Page") return mark_safe("""
  • From c07b28027670174e19da055180451257517bbf25 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 16:55:06 +0200 Subject: [PATCH 15/28] allow database access for tests --- tests/conftest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 77e07e7..1f95a98 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,10 @@ pytest_plugins = [ 'tests.fixtures' ] +@pytest.fixture(autouse=True) +def enable_db_access(db): + pass + @pytest.fixture(scope='session') def django_db_setup(django_db_setup, django_db_blocker): From 5cd87514505e31335d4f0ee0a78742a3951e07d1 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 16:56:38 +0200 Subject: [PATCH 16/28] add ve to the gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 16914b0..df72266 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ .vscode/ build/ +ve/ dist/ htmlcov/ docs/_build From b135e79c7743d476ed1b02352f4644ef57ac8af3 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 17:04:00 +0200 Subject: [PATCH 17/28] remove trailing print --- tests/unit/test_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index c5f4af5..73cc51d 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -68,6 +68,5 @@ def test_exclude_variants_with_pages_querysets(): page1 = WagtailPage(path="/", depth=0, url_path="/", title="Hoi") page2 = WagtailPage(path="/", depth=0, url_path="/", title="Hoi") pages = WagtailPage.objects.all().order_by('id') - print(pages) result = exclude_variants(pages) assert result == pages From cbb56847ae9dd5407aef006933e9aaf1adee9129 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 17:17:51 +0200 Subject: [PATCH 18/28] fix flake8 error --- tests/unit/test_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 73cc51d..0f04056 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -65,8 +65,9 @@ def test_exclude_variants_with_pages_querysets(): ''' Test that excludes variant works for querysets too ''' - page1 = WagtailPage(path="/", depth=0, url_path="/", title="Hoi") - page2 = WagtailPage(path="/", depth=0, url_path="/", title="Hoi") + for i in range(5): + page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) + page.save() pages = WagtailPage.objects.all().order_by('id') result = exclude_variants(pages) assert result == pages From f054b86e071b2d669ab11226dbe072ff8f42f20d Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Wed, 9 Jan 2019 17:25:56 +0200 Subject: [PATCH 19/28] fix flake error in conftest --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index 1f95a98..7a4081a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,7 @@ pytest_plugins = [ 'tests.fixtures' ] + @pytest.fixture(autouse=True) def enable_db_access(db): pass From 94c9efa315878fa60cfa59b2875990ff2b2485c2 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Wed, 9 Jan 2019 19:14:07 +0200 Subject: [PATCH 20/28] Bump version to 1.0.2 --- CHANGES | 4 ++++ docs/conf.py | 4 ++-- setup.cfg | 2 +- setup.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 1c93f5b..744d2e7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1.0.2 +================== + - Upgrade to Wagtail 2.2 + 1.0.1 ================== - Added RulePanel, a subclass of InlinePanel, for Rules diff --git a/docs/conf.py b/docs/conf.py index 4ffa1ce..24f6626 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,10 +55,10 @@ author = 'Lab Digital BV' # built documents. # # The short X.Y version. -version = '1.0.1' +version = '1.0.2' # The full version, including alpha/beta/rc tags. -release = '1.0.1' +release = '1.0.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.cfg b/setup.cfg index bb5813c..034b45d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.1 +current_version = 1.0.2 commit = true tag = true tag_name = {new_version} diff --git a/setup.py b/setup.py index d2667ad..24ad1ba 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ with open('README.rst') as fh: setup( name='wagtail-personalisation-molo', - version='1.0.1', + version='1.0.2', description='A forked version of Wagtail add-on for showing personalized content', author='Praekelt.org', author_email='dev@praekeltfoundation.org', From 9235932f00b3acc858b938d61471b142a10f285e Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Thu, 10 Jan 2019 12:41:53 +0200 Subject: [PATCH 21/28] update exclude varient format and add variants to tests --- src/wagtail_personalisation/utils.py | 22 +++++++++++----------- tests/unit/test_utils.py | 7 ++++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/wagtail_personalisation/utils.py b/src/wagtail_personalisation/utils.py index bdc3c31..3579911 100644 --- a/src/wagtail_personalisation/utils.py +++ b/src/wagtail_personalisation/utils.py @@ -98,18 +98,18 @@ def parse_tag(token, parser): def exclude_variants(pages): """Checks if page is not a variant - :param pages: List of pages to check - :type pages: list - :return: List of pages that aren't variants - :rtype: list + :param pages: List | Queryset of pages to check + :type pages: list or querset + :return: List|Queryset of pages that aren't variants + :rtype: list or queryset (depending on the param type) """ for page in pages: - if not ((hasattr(page, 'personalisation_metadata') is False - ) or (hasattr(page, 'personalisation_metadata') and page.personalisation_metadata is None - ) or (hasattr(page, 'personalisation_metadata') and page.personalisation_metadata.is_canonical)): - if (type(pages) == list): - pages.remove(page) - else: - pages.exclude(pk=page.pk) + if hasattr(page, 'personalisation_metadata') is not False and \ + page.personalisation_metadata is not None and \ + page.personalisation_metadata.is_canonical is not True: + if (type(pages) == list): + pages.remove(page) + else: + pages.exclude(pk=page.pk) return pages diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 0f04056..1c4a6a0 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -69,5 +69,10 @@ def test_exclude_variants_with_pages_querysets(): page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) page.save() pages = WagtailPage.objects.all().order_by('id') + # add variants + for page in pages: + page.personalisation_metadata = Metadata(is_canonical=False) + pages = WagtailPage.objects.all().order_by('id') result = exclude_variants(pages) - assert result == pages + assert type(result) == type(pages) + assert result != pages From 650e061f9165f3e61fbc98adae722052473f83a6 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Thu, 10 Jan 2019 14:47:01 +0200 Subject: [PATCH 22/28] assign pages on exclude --- src/wagtail_personalisation/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wagtail_personalisation/utils.py b/src/wagtail_personalisation/utils.py index 3579911..2cd1951 100644 --- a/src/wagtail_personalisation/utils.py +++ b/src/wagtail_personalisation/utils.py @@ -103,7 +103,6 @@ def exclude_variants(pages): :return: List|Queryset of pages that aren't variants :rtype: list or queryset (depending on the param type) """ - for page in pages: if hasattr(page, 'personalisation_metadata') is not False and \ page.personalisation_metadata is not None and \ @@ -111,5 +110,5 @@ def exclude_variants(pages): if (type(pages) == list): pages.remove(page) else: - pages.exclude(pk=page.pk) + pages = pages.exclude(pk=page.pk) return pages From ceef8063014936c778e1c5f4df92fe90e4fc31cc Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Thu, 10 Jan 2019 14:47:18 +0200 Subject: [PATCH 23/28] add tests for varient exclusion use cases --- tests/unit/test_utils.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 1c4a6a0..30f3fbb 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -69,10 +69,43 @@ def test_exclude_variants_with_pages_querysets(): page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) page.save() pages = WagtailPage.objects.all().order_by('id') + + result = exclude_variants(pages) + assert type(result) == type(pages) + assert result == pages + + +def test_exclude_variants_with_pages_querysets_not_canonical(): + ''' + Test that excludes variant works for querysets too + ''' + for i in range(5): + page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) + page.save() + pages = WagtailPage.objects.all().order_by('id') # add variants for page in pages: page.personalisation_metadata = Metadata(is_canonical=False) - pages = WagtailPage.objects.all().order_by('id') + page.save() + result = exclude_variants(pages) assert type(result) == type(pages) - assert result != pages + assert result.count() == 0 + + +def test_exclude_variants_with_pages_querysets_meta_none(): + ''' + Test that excludes variant works for querysets too + ''' + for i in range(5): + page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) + page.save() + pages = WagtailPage.objects.all().order_by('id') + # add variants + for page in pages: + page.personalisation_metadata = None + page.save() + + result = exclude_variants(pages) + assert type(result) == type(pages) + assert result == pages From 60675203c60dac8ed020a5fd6116626cbe0160b1 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Thu, 10 Jan 2019 14:51:43 +0200 Subject: [PATCH 24/28] fixed some comments --- tests/unit/test_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 30f3fbb..2b3fa15 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -63,7 +63,7 @@ def test_exclude_variants_excludes_pages_with_metadata_not_canonical(): def test_exclude_variants_with_pages_querysets(): ''' - Test that excludes variant works for querysets too + Test that excludes variant works for querysets ''' for i in range(5): page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) @@ -77,7 +77,8 @@ def test_exclude_variants_with_pages_querysets(): def test_exclude_variants_with_pages_querysets_not_canonical(): ''' - Test that excludes variant works for querysets too + Test that excludes variant works for querysets with + personalisation_metadata canonical False ''' for i in range(5): page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) @@ -95,7 +96,7 @@ def test_exclude_variants_with_pages_querysets_not_canonical(): def test_exclude_variants_with_pages_querysets_meta_none(): ''' - Test that excludes variant works for querysets too + Test that excludes variant works for querysets with meta as none ''' for i in range(5): page = WagtailPage(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i)) From 9cc6e966ba18529ad0c8508a9f035e3f3a0f7b22 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Thu, 10 Jan 2019 16:12:01 +0200 Subject: [PATCH 25/28] bugfix:exclude variant returns queryset when params is queryset --- CHANGES | 4 ++++ VERSON | 1 + 2 files changed, 5 insertions(+) create mode 100644 VERSON diff --git a/CHANGES b/CHANGES index 744d2e7..27dfc33 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1.0.3 +================== +- bugfix:exclude variant returns queryset when params is queryset + 1.0.2 ================== - Upgrade to Wagtail 2.2 diff --git a/VERSON b/VERSON new file mode 100644 index 0000000..21e8796 --- /dev/null +++ b/VERSON @@ -0,0 +1 @@ +1.0.3 From 807005461e52fab970ae39925b8bc70924658a54 Mon Sep 17 00:00:00 2001 From: sewagodimo Date: Thu, 10 Jan 2019 17:13:38 +0200 Subject: [PATCH 26/28] update version to 1.0.3 --- docs/conf.py | 4 ++-- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 24f6626..1f52eca 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,10 +55,10 @@ author = 'Lab Digital BV' # built documents. # # The short X.Y version. -version = '1.0.2' +version = '1.0.3' # The full version, including alpha/beta/rc tags. -release = '1.0.2' +release = '1.0.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.cfg b/setup.cfg index 034b45d..3e94076 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.2 +current_version = 1.0.3 commit = true tag = true tag_name = {new_version} diff --git a/setup.py b/setup.py index 24ad1ba..6c5f04f 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ with open('README.rst') as fh: setup( name='wagtail-personalisation-molo', - version='1.0.2', + version='1.0.3', description='A forked version of Wagtail add-on for showing personalized content', author='Praekelt.org', author_email='dev@praekeltfoundation.org', From 86e669e4f490628e9096644531440766e8f69e8e Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Wed, 16 Jan 2019 12:02:14 +0200 Subject: [PATCH 27/28] Add custom js files to segment create view --- src/wagtail_personalisation/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wagtail_personalisation/views.py b/src/wagtail_personalisation/views.py index 1a53591..0c8ce35 100644 --- a/src/wagtail_personalisation/views.py +++ b/src/wagtail_personalisation/views.py @@ -45,7 +45,10 @@ class SegmentModelAdmin(ModelAdmin): 'page_count', 'variant_count', 'statistics') index_view_extra_js = ['js/commons.js', 'js/index.js'] index_view_extra_css = ['css/index.css'] - form_view_extra_js = ['js/commons.js', 'js/form.js'] + form_view_extra_js = ['js/commons.js', 'js/form.js', + 'js/segment_form_control.js', + 'wagtailadmin/js/page-chooser-modal.js', + 'wagtailadmin/js/page-chooser.js'] form_view_extra_css = ['css/form.css'] def index_view(self, request): From 88263dea604bba2e54ed9552d1778c9613397a07 Mon Sep 17 00:00:00 2001 From: Kaitlyn Crawford Date: Wed, 16 Jan 2019 13:08:58 +0200 Subject: [PATCH 28/28] Bump version to 1.0.4 --- CHANGES | 4 ++++ docs/conf.py | 4 ++-- setup.cfg | 2 +- setup.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 27dfc33..2edbb28 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1.0.4 +================== +- Add custom javascript to segment forms + 1.0.3 ================== - bugfix:exclude variant returns queryset when params is queryset diff --git a/docs/conf.py b/docs/conf.py index 1f52eca..ea52dbd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,10 +55,10 @@ author = 'Lab Digital BV' # built documents. # # The short X.Y version. -version = '1.0.3' +version = '1.0.4' # The full version, including alpha/beta/rc tags. -release = '1.0.3' +release = '1.0.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.cfg b/setup.cfg index 3e94076..f3a29fb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.3 +current_version = 1.0.4 commit = true tag = true tag_name = {new_version} diff --git a/setup.py b/setup.py index 6c5f04f..7b4f62e 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ with open('README.rst') as fh: setup( name='wagtail-personalisation-molo', - version='1.0.3', + version='1.0.4', description='A forked version of Wagtail add-on for showing personalized content', author='Praekelt.org', author_email='dev@praekeltfoundation.org',