From 5aa754dd80d14e40e28a429783b1b38d01128fdc Mon Sep 17 00:00:00 2001 From: Michael van Tellingen Date: Fri, 2 Jun 2017 10:23:46 +0200 Subject: [PATCH] Rename PersonalisablePageMixin.personalisable_metadata Use PersonalisablePageMixin.personalisation_metadata instead to mirror the package name --- src/wagtail_personalisation/models.py | 2 +- src/wagtail_personalisation/wagtail_hooks.py | 4 ++-- tests/fixtures.py | 2 +- tests/unit/test_models.py | 10 +++++----- tests/unit/test_wagtail_hooks.py | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/wagtail_personalisation/models.py b/src/wagtail_personalisation/models.py index e375acc..9fe600c 100644 --- a/src/wagtail_personalisation/models.py +++ b/src/wagtail_personalisation/models.py @@ -187,7 +187,7 @@ class PersonalisablePageMixin(object): """ @cached_property - def personalisable_metadata(self): + def personalisation_metadata(self): try: metadata = self._personalisable_page_metadata except AttributeError: diff --git a/src/wagtail_personalisation/wagtail_hooks.py b/src/wagtail_personalisation/wagtail_hooks.py index 06c44bb..6aa7aa5 100644 --- a/src/wagtail_personalisation/wagtail_hooks.py +++ b/src/wagtail_personalisation/wagtail_hooks.py @@ -78,7 +78,7 @@ def serve_variation(page, request, serve_args, serve_kwargs): user_segments = adapter.get_segments() if user_segments: - metadata = page.personalisable_metadata + metadata = page.personalisation_metadata # TODO: This is never more then one page? (fix query count) variations = metadata.variants_for_segments(user_segments) @@ -96,7 +96,7 @@ def page_listing_variant_buttons(page, page_perms, is_parent=False): if not isinstance(page, models.PersonalisablePageMixin): return - metadata = page.personalisable_metadata + metadata = page.personalisation_metadata if metadata.is_canonical and metadata.get_unused_segments(): yield ButtonWithDropdownFromHook( _('Variants'), diff --git a/tests/fixtures.py b/tests/fixtures.py index 35c5661..abe04b2 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -25,7 +25,7 @@ def site(): def segmented_page(site): page = ContentPageFactory(parent=site.root_page, slug='personalised') segment = SegmentFactory() - return page.personalisable_metadata.copy_for_segment(segment) + return page.personalisation_metadata.copy_for_segment(segment) @pytest.fixture() diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py index e3e2785..d68ba13 100644 --- a/tests/unit/test_models.py +++ b/tests/unit/test_models.py @@ -19,9 +19,9 @@ def test_segment_create(): @pytest.mark.django_db def test_metadata_page_has_variations(segmented_page): - assert not segmented_page.personalisable_metadata.is_canonical - assert not segmented_page.personalisable_metadata.has_variations + assert not segmented_page.personalisation_metadata.is_canonical + assert not segmented_page.personalisation_metadata.has_variations - canonical = segmented_page.personalisable_metadata.canonical_page - assert canonical.personalisable_metadata.is_canonical - assert canonical.personalisable_metadata.has_variations + canonical = segmented_page.personalisation_metadata.canonical_page + assert canonical.personalisation_metadata.is_canonical + assert canonical.personalisation_metadata.has_variations diff --git a/tests/unit/test_wagtail_hooks.py b/tests/unit/test_wagtail_hooks.py index 14df050..94c88a5 100644 --- a/tests/unit/test_wagtail_hooks.py +++ b/tests/unit/test_wagtail_hooks.py @@ -20,7 +20,7 @@ def test_serve_variation_with_variant_no_segment(site, rf, segmented_page): args = tuple() kwargs = {} - page = segmented_page.personalisable_metadata.canonical_page + page = segmented_page.personalisation_metadata.canonical_page result = wagtail_hooks.serve_variation(page, request, args, kwargs) assert result is None @@ -31,8 +31,8 @@ def test_serve_variation_with_variant_segmented(site, rf, segmented_page): args = tuple() kwargs = {} - page = segmented_page.personalisable_metadata.canonical_page - segment = segmented_page.personalisable_metadata.segment + page = segmented_page.personalisation_metadata.canonical_page + segment = segmented_page.personalisation_metadata.segment adapter = adapters.get_segment_adapter(request) adapter.set_segments([segment])