Compare commits
9 Commits
0.15.0
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
4eb5c2fe15 | |||
dd4530203f | |||
48955675be | |||
a81c5b3560 | |||
53880228e4 | |||
2bee66d0ae | |||
16e24b6791 | |||
477bfb9665 | |||
6108469047 |
72
.github/workflows/python-test.yml
vendored
72
.github/workflows/python-test.yml
vendored
@ -23,118 +23,46 @@ jobs:
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
tox_env:
|
||||
- py36-dj22-wt25
|
||||
- py36-dj22-wt26
|
||||
- py36-dj22-wt27
|
||||
- py36-dj22-wt28
|
||||
- py36-dj22-wt29
|
||||
- py36-dj22-wt210
|
||||
- py36-dj22-wt211
|
||||
- py36-dj22-wt212
|
||||
- py36-dj22-wt213
|
||||
- py37-dj22-wt25
|
||||
- py37-dj22-wt26
|
||||
- py37-dj22-wt27
|
||||
- py37-dj22-wt28
|
||||
- py37-dj22-wt29
|
||||
- py37-dj22-wt210
|
||||
- py37-dj22-wt211
|
||||
- py37-dj22-wt212
|
||||
- py37-dj22-wt213
|
||||
- py38-dj22-wt25
|
||||
- py38-dj22-wt26
|
||||
- py38-dj22-wt27
|
||||
- py38-dj22-wt28
|
||||
- py38-dj22-wt29
|
||||
- py38-dj22-wt210
|
||||
- py38-dj22-wt211
|
||||
- py38-dj22-wt212
|
||||
- py38-dj22-wt213
|
||||
- py37-dj30-wt28
|
||||
- py37-dj30-wt29
|
||||
- py37-dj30-wt210
|
||||
- py37-dj30-wt211
|
||||
- py37-dj30-wt212
|
||||
- py37-dj30-wt213
|
||||
- py38-dj30-wt28
|
||||
- py38-dj30-wt29
|
||||
- py38-dj30-wt210
|
||||
- py38-dj30-wt211
|
||||
- py38-dj30-wt212
|
||||
- py38-dj30-wt213
|
||||
include:
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt25
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt26
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt27
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt28
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt29
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt210
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt211
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt212
|
||||
- python-version: 3.6
|
||||
tox_env: py36-dj22-wt213
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt25
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt26
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt27
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt28
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt29
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt210
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt211
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt212
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj22-wt213
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt25
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt26
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt27
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt28
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt29
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt210
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt211
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt212
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj22-wt213
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj30-wt28
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj30-wt29
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj30-wt210
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj30-wt211
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj30-wt212
|
||||
- python-version: 3.7
|
||||
tox_env: py37-dj30-wt213
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj30-wt28
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj30-wt29
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj30-wt210
|
||||
- python-version: 3.8
|
||||
tox_env: py38-dj30-wt211
|
||||
- python-version: 3.8
|
||||
|
50
.travis.yml
50
.travis.yml
@ -1,50 +0,0 @@
|
||||
---
|
||||
sudo: false
|
||||
language: python
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- python: 3.6
|
||||
env: TOXENV=lint
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django20-wagtail20
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django20-wagtail20-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django20-wagtail21
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django20-wagtail21-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django20-wagtail22
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django20-wagtail22-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django21-wagtail23
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django21-wagtail23-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django21-wagtail24
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django21-wagtail24-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django22-wagtail25
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django22-wagtail25-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django22-wagtail26
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django22-wagtail26-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django111-wagtail22
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django22-wagtail211-geoip2
|
||||
|
||||
install:
|
||||
- pip install tox codecov
|
||||
|
||||
script:
|
||||
- tox
|
||||
|
||||
after_success:
|
||||
- tox -e coverage-report
|
||||
- codecov
|
25
CHANGES
25
CHANGES
@ -1,3 +1,28 @@
|
||||
0.15.3
|
||||
=================
|
||||
- Add wagtail >= 2.15 support with get_context_data override instead of get_context
|
||||
|
||||
0.15.2
|
||||
=================
|
||||
- Replace staticfiles tag with static
|
||||
|
||||
0.15.1
|
||||
=================
|
||||
- Remove old versions from test matrix
|
||||
- Fix button support in wagtail admin for newer wagtail versions
|
||||
|
||||
0.15.0
|
||||
=================
|
||||
- Fix is_authenticated 'bool' object is not callable error
|
||||
- Add wagtail <=2.11 support
|
||||
- Use Github Actions to test package instead of Travis CI
|
||||
|
||||
0.14.0
|
||||
=================
|
||||
- Fix 'bool' object is not callable error
|
||||
- Fix deleting descendants with variants when deleting a page
|
||||
- Add wagtail 2.6 support
|
||||
|
||||
0.13.0
|
||||
=================
|
||||
- Merged Praekelt fork
|
||||
|
@ -62,10 +62,10 @@ author = 'Lab Digital BV'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.15.0'
|
||||
version = '0.15.3'
|
||||
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.15.0'
|
||||
release = '0.15.3'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.15.0
|
||||
current_version = 0.15.3
|
||||
commit = true
|
||||
tag = true
|
||||
tag_name = {new_version}
|
||||
|
2
setup.py
2
setup.py
@ -35,7 +35,7 @@ with open('README.rst') as fh:
|
||||
|
||||
setup(
|
||||
name='wagtail-personalisation',
|
||||
version='0.15.0',
|
||||
version='0.15.3',
|
||||
description='A Wagtail add-on for showing personalized content',
|
||||
author='Lab Digital BV and others',
|
||||
author_email='opensource@labdigital.nl',
|
||||
|
@ -1,5 +1,5 @@
|
||||
{% extends "modeladmin/index.html" %}
|
||||
{% load i18n l10n staticfiles modeladmin_tags %}
|
||||
{% load i18n l10n static modeladmin_tags %}
|
||||
|
||||
{% block titletag %}{{ view.get_meta_title }}{% endblock %}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{% extends "modeladmin/wagtail_personalisation/segment/base.html" %}
|
||||
{% load i18n l10n staticfiles modeladmin_tags wagtail_personalisation_filters %}
|
||||
{% load i18n l10n static modeladmin_tags wagtail_personalisation_filters %}
|
||||
|
||||
{% block toggle_view %}to List {% endblock%}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
{% extends "modeladmin/wagtail_personalisation/segment/base.html" %}
|
||||
{% load i18n l10n staticfiles modeladmin_tags wagtail_personalisation_filters %}
|
||||
{% load i18n l10n static modeladmin_tags wagtail_personalisation_filters %}
|
||||
|
||||
{% block toggle_view %}to Dashboard {% endblock%}
|
||||
|
||||
|
@ -9,6 +9,7 @@ from django.template.defaultfilters import pluralize
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from wagtail import VERSION as WAGTAIL_VERSION
|
||||
from wagtail.admin import messages
|
||||
from wagtail.admin.site_summary import PagesSummaryItem, SummaryItem
|
||||
|
||||
@ -28,18 +29,18 @@ from wagtail_personalisation.models import PersonalisablePageMetadata
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
|
||||
@hooks.register('register_admin_urls')
|
||||
@hooks.register("register_admin_urls")
|
||||
def register_admin_urls():
|
||||
"""Adds the administration urls for the personalisation apps."""
|
||||
return [
|
||||
url(r'^personalisation/', include(
|
||||
admin_urls, namespace='wagtail_personalisation')),
|
||||
url(
|
||||
r"^personalisation/",
|
||||
include(admin_urls, namespace="wagtail_personalisation"),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@hooks.register('before_serve_page')
|
||||
@hooks.register("before_serve_page")
|
||||
def set_visit_count(page, request, serve_args, serve_kwargs):
|
||||
"""Tests the provided rules to see if the request still belongs
|
||||
to a segment.
|
||||
@ -54,7 +55,7 @@ def set_visit_count(page, request, serve_args, serve_kwargs):
|
||||
adapter.add_page_visit(page)
|
||||
|
||||
|
||||
@hooks.register('before_serve_page')
|
||||
@hooks.register("before_serve_page")
|
||||
def segment_user(page, request, serve_args, serve_kwargs):
|
||||
"""Apply a segment to a visitor before serving the page.
|
||||
|
||||
@ -67,7 +68,7 @@ def segment_user(page, request, serve_args, serve_kwargs):
|
||||
adapter = get_segment_adapter(request)
|
||||
adapter.refresh()
|
||||
|
||||
forced_segment = request.GET.get('segment', None)
|
||||
forced_segment = request.GET.get("segment", None)
|
||||
if request.user.is_superuser and forced_segment is not None:
|
||||
segment = models.Segment.objects.filter(pk=forced_segment).first()
|
||||
if segment:
|
||||
@ -85,14 +86,14 @@ class UserbarSegmentedLinkItem:
|
||||
Show as segment: {self.segment.name}</a></div>"""
|
||||
|
||||
|
||||
@hooks.register('construct_wagtail_userbar')
|
||||
@hooks.register("construct_wagtail_userbar")
|
||||
def add_segment_link_items(request, items):
|
||||
for item in models.Segment.objects.enabled():
|
||||
items.append(UserbarSegmentedLinkItem(item))
|
||||
return items
|
||||
|
||||
|
||||
@hooks.register('before_serve_page')
|
||||
@hooks.register("before_serve_page")
|
||||
def serve_variant(page, request, serve_args, serve_kwargs):
|
||||
"""Apply a segment to a visitor before serving the page.
|
||||
|
||||
@ -126,13 +127,13 @@ def serve_variant(page, request, serve_args, serve_kwargs):
|
||||
return variant.serve(request, *serve_args, **serve_kwargs)
|
||||
|
||||
|
||||
@hooks.register('construct_explorer_page_queryset')
|
||||
@hooks.register("construct_explorer_page_queryset")
|
||||
def dont_show_variant(parent_page, pages, request):
|
||||
return utils.exclude_variants(pages)
|
||||
|
||||
|
||||
@hooks.register('register_page_listing_buttons')
|
||||
def page_listing_variant_buttons(page, page_perms, is_parent=False):
|
||||
@hooks.register("register_page_listing_buttons")
|
||||
def page_listing_variant_buttons(page, page_perms, is_parent=False, *args):
|
||||
"""Adds page listing buttons to personalisable pages. Shows variants for
|
||||
the page (if any) and a 'Create a new variant' button.
|
||||
|
||||
@ -143,17 +144,18 @@ def page_listing_variant_buttons(page, page_perms, is_parent=False):
|
||||
metadata = page.personalisation_metadata
|
||||
if metadata.is_canonical:
|
||||
yield ButtonWithDropdownFromHook(
|
||||
_('Variants'),
|
||||
hook_name='register_page_listing_variant_buttons',
|
||||
_("Variants"),
|
||||
hook_name="register_page_listing_variant_buttons",
|
||||
page=page,
|
||||
page_perms=page_perms,
|
||||
is_parent=is_parent,
|
||||
attrs={'target': '_blank', 'title': _('Create or edit a variant')},
|
||||
priority=100)
|
||||
attrs={"target": "_blank", "title": _("Create or edit a variant")},
|
||||
priority=100,
|
||||
)
|
||||
|
||||
|
||||
@hooks.register('register_page_listing_variant_buttons')
|
||||
def page_listing_more_buttons(page, page_perms, is_parent=False):
|
||||
@hooks.register("register_page_listing_variant_buttons")
|
||||
def page_listing_more_buttons(page, page_perms, is_parent=False, *args):
|
||||
"""Adds a 'more' button to personalisable pages allowing users to quickly
|
||||
create a new variant for the selected segment.
|
||||
|
||||
@ -164,48 +166,63 @@ def page_listing_more_buttons(page, page_perms, is_parent=False):
|
||||
metadata = page.personalisation_metadata
|
||||
|
||||
for vm in metadata.variants_metadata:
|
||||
yield Button('%s variant' % (vm.segment.name),
|
||||
reverse('wagtailadmin_pages:edit', args=[vm.variant_id]),
|
||||
attrs={"title": _('Edit this variant')},
|
||||
classes=("icon", "icon-fa-pencil"),
|
||||
priority=0)
|
||||
yield Button(
|
||||
"%s variant" % (vm.segment.name),
|
||||
reverse("wagtailadmin_pages:edit", args=[vm.variant_id]),
|
||||
attrs={"title": _("Edit this variant")},
|
||||
classes=("icon", "icon-fa-pencil"),
|
||||
priority=0,
|
||||
)
|
||||
|
||||
for segment in metadata.get_unused_segments():
|
||||
yield Button('%s variant' % (segment.name),
|
||||
reverse('segment:copy_page', args=[page.pk, segment.pk]),
|
||||
attrs={"title": _('Create this variant')},
|
||||
classes=("icon", "icon-fa-plus"),
|
||||
priority=100)
|
||||
yield Button(
|
||||
"%s variant" % (segment.name),
|
||||
reverse("segment:copy_page", args=[page.pk, segment.pk]),
|
||||
attrs={"title": _("Create this variant")},
|
||||
classes=("icon", "icon-fa-plus"),
|
||||
priority=100,
|
||||
)
|
||||
|
||||
yield Button(_('Create a new segment'),
|
||||
reverse('wagtail_personalisation_segment_modeladmin_create'),
|
||||
attrs={"title": _('Create a new segment')},
|
||||
classes=("icon", "icon-fa-snowflake-o"),
|
||||
priority=200)
|
||||
yield Button(
|
||||
_("Create a new segment"),
|
||||
reverse("wagtail_personalisation_segment_modeladmin_create"),
|
||||
attrs={"title": _("Create a new segment")},
|
||||
classes=("icon", "icon-fa-snowflake-o"),
|
||||
priority=200,
|
||||
)
|
||||
|
||||
|
||||
class CorrectedPagesSummaryItem(PagesSummaryItem):
|
||||
def get_context(self):
|
||||
def get_total_pages(self, context):
|
||||
# Perform the same check as Wagtail to get the correct count.
|
||||
# Only correct the count when a root page is available to the user.
|
||||
# The `PagesSummaryItem` will return a page count of 0 otherwise.
|
||||
# https://github.com/wagtail/wagtail/blob/5c9ff23e229acabad406c42c4e13cbaea32e6c15/wagtail/admin/site_summary.py#L38
|
||||
context = super().get_context()
|
||||
root_page = context.get('root_page', None)
|
||||
root_page = context.get("root_page", None)
|
||||
if root_page:
|
||||
pages = utils.exclude_variants(
|
||||
Page.objects.descendant_of(root_page, inclusive=True))
|
||||
Page.objects.descendant_of(root_page, inclusive=True)
|
||||
)
|
||||
page_count = pages.count()
|
||||
|
||||
if root_page.is_root():
|
||||
page_count -= 1
|
||||
|
||||
context['total_pages'] = page_count
|
||||
return page_count
|
||||
|
||||
return context
|
||||
if WAGTAIL_VERSION >= (2, 15):
|
||||
def get_context_data(self, parent_context):
|
||||
context = super().get_context_data(parent_context)
|
||||
context["total_pages"] = self.get_total_pages(context)
|
||||
return context
|
||||
else:
|
||||
def get_context(self):
|
||||
context = super().get_context()
|
||||
context["total_pages"] = self.get_total_pages(context)
|
||||
return context
|
||||
|
||||
|
||||
@hooks.register('construct_homepage_summary_items')
|
||||
@hooks.register("construct_homepage_summary_items")
|
||||
def add_corrected_pages_summary_panel(request, items):
|
||||
"""Replaces the Pages summary panel to hide variants."""
|
||||
for index, item in enumerate(items):
|
||||
@ -218,28 +235,39 @@ class SegmentSummaryPanel(SummaryItem):
|
||||
site and allowing quick access to the Segment dashboard.
|
||||
|
||||
"""
|
||||
|
||||
order = 2000
|
||||
|
||||
def render(self):
|
||||
segment_count = models.Segment.objects.count()
|
||||
target_url = reverse('wagtail_personalisation_segment_modeladmin_index')
|
||||
target_url = reverse("wagtail_personalisation_segment_modeladmin_index")
|
||||
title = _("Segments")
|
||||
return mark_safe("""
|
||||
return mark_safe(
|
||||
"""
|
||||
<li class="icon icon-fa-snowflake-o">
|
||||
<a href="{}"><span>{}</span>{}</a>
|
||||
</li>""".format(target_url, segment_count, title))
|
||||
</li>""".format(
|
||||
target_url, segment_count, title
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
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("""
|
||||
return mark_safe(
|
||||
"""
|
||||
<li class="icon icon-fa-file-o">
|
||||
<span>{}</span>{}{}
|
||||
</li>""".format(page_count, title, pluralize(page_count)))
|
||||
</li>""".format(
|
||||
page_count, title, pluralize(page_count)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class VariantPagesSummaryPanel(PagesSummaryItem):
|
||||
@ -247,15 +275,20 @@ class VariantPagesSummaryPanel(PagesSummaryItem):
|
||||
|
||||
def render(self):
|
||||
page_count = models.PersonalisablePageMetadata.objects.filter(
|
||||
segment__isnull=False).count()
|
||||
segment__isnull=False
|
||||
).count()
|
||||
title = _("Variant")
|
||||
return mark_safe("""
|
||||
return mark_safe(
|
||||
"""
|
||||
<li class="icon icon-fa-files-o">
|
||||
<span>{}</span>{}{}
|
||||
</li>""".format(page_count, title, pluralize(page_count)))
|
||||
</li>""".format(
|
||||
page_count, title, pluralize(page_count)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@hooks.register('construct_homepage_summary_items')
|
||||
@hooks.register("construct_homepage_summary_items")
|
||||
def add_personalisation_summary_panels(request, items):
|
||||
"""Adds a summary panel to the Wagtail dashboard showing the total amount
|
||||
of segments on the site and allowing quick access to the Segment
|
||||
@ -267,20 +300,21 @@ def add_personalisation_summary_panels(request, items):
|
||||
items.append(VariantPagesSummaryPanel(request))
|
||||
|
||||
|
||||
@hooks.register('before_delete_page')
|
||||
@hooks.register("before_delete_page")
|
||||
def delete_related_variants(request, page):
|
||||
if not isinstance(page, models.PersonalisablePageMixin) \
|
||||
or not page.personalisation_metadata.is_canonical:
|
||||
if (
|
||||
not isinstance(page, models.PersonalisablePageMixin)
|
||||
or not page.personalisation_metadata.is_canonical
|
||||
):
|
||||
return
|
||||
# Get a list of related personalisation metadata for all the related
|
||||
# variants.
|
||||
variants_metadata = (
|
||||
page.personalisation_metadata.variants_metadata
|
||||
.select_related('variant')
|
||||
variants_metadata = page.personalisation_metadata.variants_metadata.select_related(
|
||||
"variant"
|
||||
)
|
||||
next_url = get_valid_next_url_from_request(request)
|
||||
|
||||
if request.method == 'POST':
|
||||
if request.method == "POST":
|
||||
parent_id = page.get_parent().id
|
||||
with transaction.atomic():
|
||||
# To ensure variants are deleted for all descendants, start with
|
||||
@ -291,36 +325,36 @@ def delete_related_variants(request, page):
|
||||
for metadata in PersonalisablePageMetadata.objects.filter(
|
||||
canonical_page__in=page.get_descendants(inclusive=True),
|
||||
variant=F("canonical_page"),
|
||||
).order_by('-canonical_page__depth'):
|
||||
for variant_metadata in metadata.variants_metadata.select_related('variant'):
|
||||
).order_by("-canonical_page__depth"):
|
||||
for variant_metadata in metadata.variants_metadata.select_related(
|
||||
"variant"
|
||||
):
|
||||
# Call delete() on objects to trigger any signals or hooks.
|
||||
variant_metadata.variant.delete()
|
||||
metadata.delete()
|
||||
metadata.canonical_page.delete()
|
||||
|
||||
msg = _("Page '{0}' and its variants deleted.")
|
||||
messages.success(
|
||||
request,
|
||||
msg.format(page.get_admin_display_title())
|
||||
)
|
||||
messages.success(request, msg.format(page.get_admin_display_title()))
|
||||
|
||||
for fn in hooks.get_hooks('after_delete_page'):
|
||||
for fn in hooks.get_hooks("after_delete_page"):
|
||||
result = fn(request, page)
|
||||
if hasattr(result, 'status_code'):
|
||||
if hasattr(result, "status_code"):
|
||||
return result
|
||||
|
||||
if next_url:
|
||||
return redirect(next_url)
|
||||
return redirect('wagtailadmin_explore', parent_id)
|
||||
return redirect("wagtailadmin_explore", parent_id)
|
||||
|
||||
return render(
|
||||
request,
|
||||
'wagtailadmin/pages/wagtail_personalisation/confirm_delete.html', {
|
||||
'page': page,
|
||||
'descendant_count': page.get_descendant_count(),
|
||||
'next': next_url,
|
||||
'variants': Page.objects.filter(
|
||||
pk__in=variants_metadata.values_list('variant_id')
|
||||
)
|
||||
}
|
||||
"wagtailadmin/pages/wagtail_personalisation/confirm_delete.html",
|
||||
{
|
||||
"page": page,
|
||||
"descendant_count": page.get_descendant_count(),
|
||||
"next": next_url,
|
||||
"variants": Page.objects.filter(
|
||||
pk__in=variants_metadata.values_list("variant_id")
|
||||
),
|
||||
},
|
||||
)
|
||||
|
13
tox.ini
13
tox.ini
@ -1,8 +1,8 @@
|
||||
[tox]
|
||||
envlist =
|
||||
flake8
|
||||
py{36,37,38}-dj{22}-wt{25,26,27,28,29,210,211,212,213}
|
||||
py{37,38}-dj{30,31}-wt{28,29,210,211,212,213}
|
||||
py{36,37,38}-dj{22}-wt{211,212,213}
|
||||
py{37,38}-dj{30,31}-wt{211,212,213}
|
||||
|
||||
[gh-actions]
|
||||
python =
|
||||
@ -21,19 +21,10 @@ deps =
|
||||
dj22: Django>=2.2.8,<2.3
|
||||
dj30: Django>=3.0,<3.1
|
||||
dj31: Django>=3.1,<3.2
|
||||
wt23: wagtail>=2.3,<2.4
|
||||
wt24: wagtail>=2.4,<2.5
|
||||
wt25: wagtail>=2.5,<2.6
|
||||
wt26: wagtail>=2.6,<2.7
|
||||
wt27: wagtail>=2.7,<2.8
|
||||
wt28: wagtail>=2.8,<2.9
|
||||
wt29: wagtail>=2.9,<2.10
|
||||
wt210: wagtail>=2.10,<2.11
|
||||
wt211: wagtail>=2.11,<2.12
|
||||
wt212: wagtail>=2.12,<2.13
|
||||
wt213: wagtail>=2.13,<2.14
|
||||
geoip2: geoip2
|
||||
django111: django>=1.11,<1.12
|
||||
|
||||
[testenv:coverage-report]
|
||||
basepython = python3.6
|
||||
|
12
yarn.lock
12
yarn.lock
@ -307,9 +307,9 @@ async-throttle@^1.1.0:
|
||||
integrity sha1-Ip5/P6eip5fobzYOYwmggiTU+no=
|
||||
|
||||
async@^2.1.2:
|
||||
version "2.6.3"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
|
||||
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
|
||||
version "2.6.4"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
|
||||
integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==
|
||||
dependencies:
|
||||
lodash "^4.17.14"
|
||||
|
||||
@ -4953,9 +4953,9 @@ lodash.uniq@^4.5.0:
|
||||
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
|
||||
|
||||
lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@~4.17.10, lodash@~4.17.11:
|
||||
version "4.17.15"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
||||
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
|
||||
logalot@^2.0.0:
|
||||
version "2.1.0"
|
||||
|
Reference in New Issue
Block a user