Adds stream fields to the sandbox
This commit is contained in:
committed by
Michael van Tellingen
parent
0776d2300a
commit
46d86d852d
@@ -1,14 +1,12 @@
|
|||||||
[
|
[{
|
||||||
{
|
|
||||||
"model": "wagtail_personalisation.timerule",
|
"model": "wagtail_personalisation.timerule",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
"fields": {
|
"fields": {
|
||||||
"segment": 2,
|
"segment": 2,
|
||||||
"start_time": "06:00:00",
|
"start_time": "06:00:00",
|
||||||
"end_time": "10:00:00"
|
"end_time": "11:00:00"
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "wagtail_personalisation.visitcountrule",
|
"model": "wagtail_personalisation.visitcountrule",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
"fields": {
|
"fields": {
|
||||||
@@ -17,38 +15,35 @@
|
|||||||
"count": 3,
|
"count": 3,
|
||||||
"counted_page": 3
|
"counted_page": 3
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "wagtail_personalisation.segment",
|
"model": "wagtail_personalisation.segment",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "Returning Rook",
|
"name": "Returning Rook",
|
||||||
"create_date": "2017-06-02T05:38:02.304Z",
|
"create_date": "2017-06-02T05:38:02.304Z",
|
||||||
"edit_date": "2017-06-02T05:38:02.304Z",
|
"edit_date": "2017-06-02T10:58:39.399Z",
|
||||||
"enable_date": "2017-06-02T05:38:02.290Z",
|
"enable_date": "2017-06-02T10:58:39.389Z",
|
||||||
"disable_date": null,
|
"disable_date": "2017-06-02T10:34:51.722Z",
|
||||||
"visit_count": 0,
|
"visit_count": 0,
|
||||||
"status": "enabled",
|
"status": "enabled",
|
||||||
"persistent": false,
|
"persistent": false,
|
||||||
"match_any": false
|
"match_any": false
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "wagtail_personalisation.segment",
|
"model": "wagtail_personalisation.segment",
|
||||||
"pk": 2,
|
"pk": 2,
|
||||||
"fields": {
|
"fields": {
|
||||||
"name": "Early Birds",
|
"name": "Early Birds",
|
||||||
"create_date": "2017-06-02T05:38:14.749Z",
|
"create_date": "2017-06-02T05:38:14.749Z",
|
||||||
"edit_date": "2017-06-02T05:38:14.750Z",
|
"edit_date": "2017-06-02T10:57:44.504Z",
|
||||||
"enable_date": "2017-06-02T05:38:14.736Z",
|
"enable_date": "2017-06-02T10:57:44.497Z",
|
||||||
"disable_date": null,
|
"disable_date": "2017-06-02T10:57:39.984Z",
|
||||||
"visit_count": 0,
|
"visit_count": 1,
|
||||||
"status": "enabled",
|
"status": "enabled",
|
||||||
"persistent": false,
|
"persistent": false,
|
||||||
"match_any": false
|
"match_any": false
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "wagtail_personalisation.personalisablepagemetadata",
|
"model": "wagtail_personalisation.personalisablepagemetadata",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
"fields": {
|
"fields": {
|
||||||
@@ -56,8 +51,7 @@
|
|||||||
"variant": 3,
|
"variant": 3,
|
||||||
"segment": null
|
"segment": null
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "wagtail_personalisation.personalisablepagemetadata",
|
"model": "wagtail_personalisation.personalisablepagemetadata",
|
||||||
"pk": 2,
|
"pk": 2,
|
||||||
"fields": {
|
"fields": {
|
||||||
@@ -65,22 +59,45 @@
|
|||||||
"variant": 4,
|
"variant": 4,
|
||||||
"segment": 1
|
"segment": 1
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "home.homepage",
|
"model": "home.homepage",
|
||||||
"pk": 3,
|
"pk": 3,
|
||||||
"fields": {
|
"fields": {
|
||||||
"text_content": "<p>Thank you for trying <a href=\"http://wagxperience.io\" target=\"_blank\">Wagxperience</a>!</p>"
|
"intro": "<p>Thank you for trying <a href=\"http://wagxperience.io\">Wagxperience</a>!</p>",
|
||||||
|
"body": "[{\"type\": \"personalisable_paragraph\", \"value\": {\"segment\": \"2\", \"paragraph\": \"<p>You are an early bird!</p>\"}}]"
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "home.homepage",
|
"model": "home.homepage",
|
||||||
"pk": 4,
|
"pk": 4,
|
||||||
"fields": {
|
"fields": {
|
||||||
"text_content": "<p>Thank you for trying <a href=\"http://wagxperience.io\">Wagxperience</a>!</p><p>You've visited the homepage more than 3 times!</p>"
|
"intro": "<p>Thank you for trying <a href=\"http://wagxperience.io\">Wagxperience</a>!</p><p>You've visited the homepage more than 3 times!</p>",
|
||||||
|
"body": "[]"
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
"model": "wagtailcore.page",
|
||||||
|
"pk": 1,
|
||||||
|
"fields": {
|
||||||
|
"path": "0001",
|
||||||
|
"depth": 1,
|
||||||
|
"numchild": 1,
|
||||||
|
"title": "Root",
|
||||||
|
"slug": "root",
|
||||||
|
"content_type": 1,
|
||||||
|
"live": true,
|
||||||
|
"has_unpublished_changes": false,
|
||||||
|
"url_path": "/",
|
||||||
|
"owner": null,
|
||||||
|
"seo_title": "",
|
||||||
|
"show_in_menus": false,
|
||||||
|
"search_description": "",
|
||||||
|
"go_live_at": null,
|
||||||
|
"expire_at": null,
|
||||||
|
"expired": false,
|
||||||
|
"locked": false,
|
||||||
|
"first_published_at": null,
|
||||||
|
"latest_revision_created_at": null
|
||||||
|
}
|
||||||
|
}, {
|
||||||
"model": "wagtailcore.page",
|
"model": "wagtailcore.page",
|
||||||
"pk": 3,
|
"pk": 3,
|
||||||
"fields": {
|
"fields": {
|
||||||
@@ -101,11 +118,10 @@
|
|||||||
"expire_at": null,
|
"expire_at": null,
|
||||||
"expired": false,
|
"expired": false,
|
||||||
"locked": false,
|
"locked": false,
|
||||||
"first_published_at": null,
|
"first_published_at": "2017-06-02T10:35:34.706Z",
|
||||||
"latest_revision_created_at": null
|
"latest_revision_created_at": "2017-06-02T10:35:34.565Z"
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"model": "wagtailcore.page",
|
"model": "wagtailcore.page",
|
||||||
"pk": 4,
|
"pk": 4,
|
||||||
"fields": {
|
"fields": {
|
||||||
@@ -129,5 +145,4 @@
|
|||||||
"first_published_at": "2017-06-02T05:38:53.568Z",
|
"first_published_at": "2017-06-02T05:38:53.568Z",
|
||||||
"latest_revision_created_at": "2017-06-02T05:38:53.390Z"
|
"latest_revision_created_at": "2017-06-02T05:38:53.390Z"
|
||||||
}
|
}
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
|
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
import wagtail.wagtailcore.fields
|
import wagtail.wagtailcore.fields
|
||||||
|
import wagtail_personalisation
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -15,9 +16,15 @@ class Migration(migrations.Migration):
|
|||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='homepage',
|
model_name='homepage',
|
||||||
name='text_content',
|
name='intro',
|
||||||
field=wagtail.wagtailcore.fields.RichTextField(
|
field=wagtail.wagtailcore.fields.RichTextField(
|
||||||
default='<p>Thank you for trying <a href="http://wagxperience.io" target="_blank">Wagxperience</a>!</p>'),
|
default='<p>Thank you for trying <a href="http://wagxperience.io" target="_blank">Wagxperience</a>!</p>'),
|
||||||
preserve_default=False,
|
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=''),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@@ -1,15 +1,23 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
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.wagtailcore.models import Page
|
||||||
from wagtail.wagtailadmin.edit_handlers import RichTextFieldPanel
|
|
||||||
from wagtail.wagtailcore.fields import RichTextField
|
|
||||||
|
|
||||||
from wagtail_personalisation.models import PersonalisablePageMixin
|
from wagtail_personalisation.models import PersonalisablePageMixin
|
||||||
|
from wagtail_personalisation.blocks import PersonalisedStructBlock
|
||||||
|
|
||||||
|
|
||||||
class HomePage(PersonalisablePageMixin, Page):
|
class HomePage(PersonalisablePageMixin, Page):
|
||||||
text_content = RichTextField()
|
intro = RichTextField()
|
||||||
|
body = StreamField([
|
||||||
|
('personalisable_paragraph', PersonalisedStructBlock([
|
||||||
|
('paragraph', blocks.RichTextBlock()),
|
||||||
|
], icon='pilcrow'))
|
||||||
|
])
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
RichTextFieldPanel('text_content')
|
RichTextFieldPanel('intro'),
|
||||||
|
StreamFieldPanel('body'),
|
||||||
]
|
]
|
||||||
|
@@ -7,8 +7,12 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Wagtail Personalisation</h1>
|
<h1>Wagtail Personalisation</h1>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2>{{ self.title }}</h2>
|
<h2>{{ self.title }}</h2>
|
||||||
|
|
||||||
{{ self.text_content|richtext }}
|
{{ self.intro|richtext }}
|
||||||
|
|
||||||
|
{% for block in page.body %}
|
||||||
|
<div>{% include_block block %}</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Reference in New Issue
Block a user