Skip to content

Commit

Permalink
Rename PersonalisablePageMixin.personalisable_metadata
Browse files Browse the repository at this point in the history
Use PersonalisablePageMixin.personalisation_metadata instead to mirror
the package name
  • Loading branch information
mvantellingen committed Jun 2, 2017
1 parent 282baa4 commit 5aa754d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/wagtail_personalisation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/wagtail_personalisation/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions tests/unit/test_wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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])
Expand Down

0 comments on commit 5aa754d

Please sign in to comment.