7

Remove custom wagtail page form

THe older page form allowed to change segment settings inline but since
support for this was temporarily removed in an earlier commit we can
clean this up too
This commit is contained in:
Michael van Tellingen
2017-06-01 13:51:13 +02:00
parent dda0bc720e
commit 29001fac8e
3 changed files with 21 additions and 51 deletions

View File

@ -1,43 +0,0 @@
from wagtail.wagtailadmin.forms import WagtailAdminPageForm
class AdminPersonalisablePageForm(WagtailAdminPageForm):
"""The personalisable page form that allows creation of variants."""
def save(self, commit=True):
"""Save a copy of the original page, linked to a segment.
:returns: The original page, or a new page.
:rtype: wagtail_personalisation.models.PersonalisablePage
"""
page = super(AdminPersonalisablePageForm, self).save(commit=False)
if page.segment:
segment = page.segment
slug = "{}-{}".format(page.slug, segment.encoded_name())
title = "{} ({})".format(page.title, segment.name)
update_attrs = {
'title': title,
'slug': slug,
'segment': segment,
'live': False,
'canonical_page': page,
'is_segmented': True,
}
if page.is_segmented:
slug = "{}-{}".format(
page.canonical_page.slug, segment.encoded_name())
title = "{} ({})".format(
page.canonical_page.title, segment.name)
page.slug = slug
page.title = title
page.save()
return page
else:
new_page = page.copy(
update_attrs=update_attrs, copy_revisions=False)
return new_page
return page