Commit 1bb91ffe authored by gijs's avatar gijs
Browse files

New structure for projects.

parent a4790527
# Generated by Django 3.1.2 on 2021-03-19 11:06
from django.db import migrations
import projects.models
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.snippets.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0003_homepage_body'),
]
operations = [
migrations.AlterField(
model_name='homepage',
name='body',
field=wagtail.core.fields.StreamField([('Quote', wagtail.core.blocks.StructBlock([('Quote', wagtail.snippets.blocks.SnippetChooserBlock(projects.models.Quote)), ('Size', wagtail.core.blocks.ChoiceBlock(choices=[(0, '1'), (1, '2'), (2, '3')]))])), ('Project', wagtail.core.blocks.StructBlock([('Project', wagtail.snippets.blocks.SnippetChooserBlock(projects.models.Project)), ('Size', wagtail.core.blocks.ChoiceBlock(choices=[(0, '1'), (1, '2'), (2, '3')]))])), ('Image', wagtail.core.blocks.StructBlock([('Image', wagtail.snippets.blocks.SnippetChooserBlock(projects.models.Image)), ('Size', wagtail.core.blocks.ChoiceBlock(choices=[(0, '1'), (1, '2'), (2, '3')]))]))]),
),
]
# Generated by Django 3.1.2 on 2021-03-24 12:06
from django.db import migrations
import projects.models
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.snippets.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0004_auto_20210319_1106'),
]
operations = [
migrations.AlterField(
model_name='homepage',
name='body',
field=wagtail.core.fields.StreamField([('Quote', wagtail.core.blocks.StructBlock([('Quote', wagtail.snippets.blocks.SnippetChooserBlock(projects.models.Quote)), ('Size', wagtail.core.blocks.ChoiceBlock(choices=[(0, '1'), (1, '2'), (2, '3')]))], template='home/partials/quote.html')), ('Project', wagtail.core.blocks.StructBlock([('Project', wagtail.core.blocks.PageChooserBlock(projects.models.ProjectPage)), ('Size', wagtail.core.blocks.ChoiceBlock(choices=[(0, '1'), (1, '2'), (2, '3')]))], template='home/partials/project.html')), ('Image', wagtail.core.blocks.StructBlock([('Image', wagtail.snippets.blocks.SnippetChooserBlock(projects.models.Image)), ('Size', wagtail.core.blocks.ChoiceBlock(choices=[(0, '1'), (1, '2'), (2, '3')]))], template='home/partials/image.html'))]),
),
]
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.fields import StreamField
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.core import blocks
from wagtail.snippets.blocks import SnippetChooserBlock
from projects.models import Quote, ProjectPage, Image
sizeBlockChoices = (
(0, '1'),
(1, '2'),
(2, '3')
)
class HomePage(Page):
body = RichTextField(blank=True)
body = StreamField([
('Quote', blocks.StructBlock([
('Quote', SnippetChooserBlock(Quote)),
('Size', blocks.ChoiceBlock(choices=sizeBlockChoices))
], template='home/partials/quote.html')),
('Project', blocks.StructBlock([
('Project', blocks.PageChooserBlock(ProjectPage)),
('Size', blocks.ChoiceBlock(choices=sizeBlockChoices))
], template='home/partials/project.html')),
('Image', blocks.StructBlock([
('Image', SnippetChooserBlock(Image)),
('Size', blocks.ChoiceBlock(choices=sizeBlockChoices))
], template='home/partials/image.html'))
])
content_panels = Page.content_panels + [
FieldPanel('body', classname="full"),
]
pass
StreamFieldPanel('body', classname="full"),
]
\ No newline at end of file
......@@ -5,5 +5,7 @@
{% block body_class %}template-homepage{% endblock %}
{% block content %}
{{ page.body|richtext }}
{% for block in page.body %}
{% include_block block %}
{% endfor %}
{% endblock %}
\ No newline at end of file
<section class="block" data-type="image" data-size="{{ value.Size }}">
{{ value.Image }}
</section>
\ No newline at end of file
<section class="block" data-type="project" data-size="{{ value.Size }}">
{{ value.Project.title }}
{{ value.Project.coverImage }}
</section>
\ No newline at end of file
{% load wagtailcore_tags %}
<section class="block" data-type="quote" data-size="{{ value.Size }}">
<blockquote>
{{ value.Quote.quote|richtext }}
</blockquote>
<section class="quote--attribution">
{{ value.Quote.attribution }}
</section>
</section>
\ No newline at end of file
# Generated by Django 3.1.2 on 2021-03-12 16:35
from django.db import migrations, models
import projects.models
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('projects', '0003_auto_20210205_0907'),
]
operations = [
migrations.CreateModel(
name='Project',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('location', models.CharField(blank=True, max_length=250)),
('short_description', wagtail.core.fields.RichTextField()),
('body', wagtail.core.fields.StreamField([('heading', projects.models.HeadingBlock()), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('quote', wagtail.core.blocks.BlockQuoteBlock()), ('datablock', wagtail.core.blocks.StreamBlock([('datarow', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.ChoiceBlock(choices=[(0, 'Status'), (1, 'Procedure'), (2, 'Area'), (3, 'Budget'), (4, 'Team: Architecture'), (5, 'Team: Public space'), (6, 'Team: Landscape'), (7, 'Team: Structure Ir'), (8, 'Team: HVAC Ir'), (9, 'Team: Energy performance '), (10, 'Team: Acoustic '), (11, 'Team: Graphic Design'), (12, 'Team: Artist collaborator'), (13, 'Team: BIM manager'), (14, 'Team: Participation'), (15, 'Team: Design'), (16, 'Sub-contractor: Architecture'), (17, 'Sub-contractor: Public space'), (18, 'Sub-contractor: Landscape'), (19, 'Sub-contractor: Structure Ir'), (20, 'Sub-contractor: HVAC Ir'), (21, 'Sub-contractor: Energy performance '), (22, 'Sub-contractor: Acoustic '), (23, 'Sub-contractor: Graphic Design'), (24, 'Sub-contractor: Artist collaborator'), (25, 'Sub-contractor: BIM manager'), (26, 'Sub-contractor: Participation'), (27, 'Sub-contractor: Design'), (28, 'Built area'), (29, 'Renovated area'), (30, 'Surroundings area'), (31, 'Initial budget'), (32, 'Adjudication budget'), (33, 'Final budget'), (34, 'Study start'), (35, 'Expeted delivery date'), (36, 'Delivery date')], classname='field-col col6', form_classname='field-col col6')), ('value', wagtail.core.blocks.CharBlock(classname='field-col col6', form_classname='field-col col6'))])), ('dataheader', wagtail.core.blocks.CharBlock())], icon='table', template='projects/blocks/datablock.html')), ('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock()), ('gallery', wagtail.core.blocks.StreamBlock([('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock())]))])),
],
),
migrations.AlterField(
model_name='projectpage',
name='body',
field=wagtail.core.fields.StreamField([('heading', projects.models.HeadingBlock()), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('quote', wagtail.core.blocks.BlockQuoteBlock()), ('datablock', wagtail.core.blocks.StreamBlock([('datarow', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.ChoiceBlock(choices=[(0, 'Status'), (1, 'Procedure'), (2, 'Area'), (3, 'Budget'), (4, 'Team: Architecture'), (5, 'Team: Public space'), (6, 'Team: Landscape'), (7, 'Team: Structure Ir'), (8, 'Team: HVAC Ir'), (9, 'Team: Energy performance '), (10, 'Team: Acoustic '), (11, 'Team: Graphic Design'), (12, 'Team: Artist collaborator'), (13, 'Team: BIM manager'), (14, 'Team: Participation'), (15, 'Team: Design'), (16, 'Sub-contractor: Architecture'), (17, 'Sub-contractor: Public space'), (18, 'Sub-contractor: Landscape'), (19, 'Sub-contractor: Structure Ir'), (20, 'Sub-contractor: HVAC Ir'), (21, 'Sub-contractor: Energy performance '), (22, 'Sub-contractor: Acoustic '), (23, 'Sub-contractor: Graphic Design'), (24, 'Sub-contractor: Artist collaborator'), (25, 'Sub-contractor: BIM manager'), (26, 'Sub-contractor: Participation'), (27, 'Sub-contractor: Design'), (28, 'Built area'), (29, 'Renovated area'), (30, 'Surroundings area'), (31, 'Initial budget'), (32, 'Adjudication budget'), (33, 'Final budget'), (34, 'Study start'), (35, 'Expeted delivery date'), (36, 'Delivery date')], classname='field-col col6', form_classname='field-col col6')), ('value', wagtail.core.blocks.CharBlock(classname='field-col col6', form_classname='field-col col6'))])), ('dataheader', wagtail.core.blocks.CharBlock())], icon='table', template='projects/blocks/datablock.html')), ('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock()), ('gallery', wagtail.core.blocks.StreamBlock([('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock())]))]),
),
]
# Generated by Django 3.1.2 on 2021-03-12 16:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('projects', '0004_auto_20210312_1635'),
]
operations = [
migrations.AddField(
model_name='project',
name='title',
field=models.CharField(default='Title', max_length=250),
preserve_default=False,
),
]
# Generated by Django 3.1.2 on 2021-03-18 16:39
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('projects', '0005_project_title'),
]
operations = [
migrations.AddField(
model_name='project',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='project',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
]
# Generated by Django 3.1.2 on 2021-03-19 09:20
from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.fields
import wagtail.search.index
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0022_uploadedimage'),
('projects', '0006_auto_20210318_1639'),
]
operations = [
migrations.CreateModel(
name='Quote',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quote', wagtail.core.fields.RichTextField()),
('attribution', models.CharField(blank=True, max_length=250)),
],
bases=(wagtail.search.index.Indexed, models.Model),
),
migrations.CreateModel(
name='Image',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('caption', wagtail.core.fields.RichTextField()),
('image', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailimages.image')),
],
bases=(wagtail.search.index.Indexed, models.Model),
),
]
# Generated by Django 3.1.2 on 2021-03-19 09:22
from django.db import migrations
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [
('projects', '0007_image_quote'),
]
operations = [
migrations.AlterField(
model_name='image',
name='caption',
field=wagtail.core.fields.RichTextField(blank=True),
),
]
# Generated by Django 3.1.2 on 2021-03-19 10:12
from django.db import migrations
import projects.models
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
import wagtail.snippets.blocks
class Migration(migrations.Migration):
dependencies = [
('projects', '0008_auto_20210319_0922'),
]
operations = [
migrations.RemoveField(
model_name='projectpage',
name='location',
),
migrations.AlterField(
model_name='project',
name='body',
field=wagtail.core.fields.StreamField([('heading', projects.models.HeadingBlock()), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('quote', wagtail.core.blocks.BlockQuoteBlock()), ('quotesnippet', wagtail.snippets.blocks.SnippetChooserBlock('Quote')), ('datablock', wagtail.core.blocks.StreamBlock([('datarow', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.ChoiceBlock(choices=[(0, 'Status'), (1, 'Procedure'), (2, 'Area'), (3, 'Budget'), (4, 'Team: Architecture'), (5, 'Team: Public space'), (6, 'Team: Landscape'), (7, 'Team: Structure Ir'), (8, 'Team: HVAC Ir'), (9, 'Team: Energy performance '), (10, 'Team: Acoustic '), (11, 'Team: Graphic Design'), (12, 'Team: Artist collaborator'), (13, 'Team: BIM manager'), (14, 'Team: Participation'), (15, 'Team: Design'), (16, 'Sub-contractor: Architecture'), (17, 'Sub-contractor: Public space'), (18, 'Sub-contractor: Landscape'), (19, 'Sub-contractor: Structure Ir'), (20, 'Sub-contractor: HVAC Ir'), (21, 'Sub-contractor: Energy performance '), (22, 'Sub-contractor: Acoustic '), (23, 'Sub-contractor: Graphic Design'), (24, 'Sub-contractor: Artist collaborator'), (25, 'Sub-contractor: BIM manager'), (26, 'Sub-contractor: Participation'), (27, 'Sub-contractor: Design'), (28, 'Built area'), (29, 'Renovated area'), (30, 'Surroundings area'), (31, 'Initial budget'), (32, 'Adjudication budget'), (33, 'Final budget'), (34, 'Study start'), (35, 'Expeted delivery date'), (36, 'Delivery date')], classname='field-col col6', form_classname='field-col col6')), ('value', wagtail.core.blocks.CharBlock(classname='field-col col6', form_classname='field-col col6'))])), ('dataheader', wagtail.core.blocks.CharBlock())], icon='table', template='projects/blocks/datablock.html')), ('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock()), ('gallery', wagtail.core.blocks.StreamBlock([('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock())]))]),
),
migrations.AlterField(
model_name='projectpage',
name='body',
field=wagtail.core.fields.StreamField([('Project', wagtail.snippets.blocks.SnippetChooserBlock('project'))]),
),
]
# Generated by Django 3.1.2 on 2021-03-19 10:32
from django.db import migrations, models
import django.db.models.deletion
import projects.models
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
import wagtail.snippets.blocks
class Migration(migrations.Migration):
dependencies = [
('projects', '0009_auto_20210319_1012'),
]
operations = [
migrations.RemoveField(
model_name='projectpage',
name='body',
),
migrations.AddField(
model_name='projectpage',
name='snippet',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='projects.project'),
preserve_default=False,
),
migrations.AlterField(
model_name='project',
name='body',
field=wagtail.core.fields.StreamField([('heading', projects.models.HeadingBlock()), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('quote', wagtail.core.blocks.BlockQuoteBlock()), ('quotesnippet', wagtail.snippets.blocks.SnippetChooserBlock(projects.models.Quote)), ('datablock', wagtail.core.blocks.StreamBlock([('datarow', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.ChoiceBlock(choices=[(0, 'Status'), (1, 'Procedure'), (2, 'Area'), (3, 'Budget'), (4, 'Team: Architecture'), (5, 'Team: Public space'), (6, 'Team: Landscape'), (7, 'Team: Structure Ir'), (8, 'Team: HVAC Ir'), (9, 'Team: Energy performance '), (10, 'Team: Acoustic '), (11, 'Team: Graphic Design'), (12, 'Team: Artist collaborator'), (13, 'Team: BIM manager'), (14, 'Team: Participation'), (15, 'Team: Design'), (16, 'Sub-contractor: Architecture'), (17, 'Sub-contractor: Public space'), (18, 'Sub-contractor: Landscape'), (19, 'Sub-contractor: Structure Ir'), (20, 'Sub-contractor: HVAC Ir'), (21, 'Sub-contractor: Energy performance '), (22, 'Sub-contractor: Acoustic '), (23, 'Sub-contractor: Graphic Design'), (24, 'Sub-contractor: Artist collaborator'), (25, 'Sub-contractor: BIM manager'), (26, 'Sub-contractor: Participation'), (27, 'Sub-contractor: Design'), (28, 'Built area'), (29, 'Renovated area'), (30, 'Surroundings area'), (31, 'Initial budget'), (32, 'Adjudication budget'), (33, 'Final budget'), (34, 'Study start'), (35, 'Expeted delivery date'), (36, 'Delivery date')], classname='field-col col6', form_classname='field-col col6')), ('value', wagtail.core.blocks.CharBlock(classname='field-col col6', form_classname='field-col col6'))])), ('dataheader', wagtail.core.blocks.CharBlock())], icon='table', template='projects/blocks/datablock.html')), ('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock()), ('gallery', wagtail.core.blocks.StreamBlock([('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock())]))]),
),
]
# Generated by Django 3.1.2 on 2021-03-19 10:35
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0022_uploadedimage'),
('projects', '0010_auto_20210319_1032'),
]
operations = [
migrations.AddField(
model_name='projectpage',
name='coverImage',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'),
),
]
# Generated by Django 3.1.2 on 2021-03-24 12:06
from django.db import migrations, models
import django.utils.timezone
import projects.models
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
import wagtail.snippets.blocks
class Migration(migrations.Migration):
dependencies = [
('projects', '0011_projectpage_coverimage'),
]
operations = [
migrations.RemoveField(
model_name='project',
name='location',
),
migrations.RemoveField(
model_name='projectpage',
name='coverImage',
),
migrations.RemoveField(
model_name='projectpage',
name='short_description',
),
migrations.RemoveField(
model_name='projectpage',
name='snippet',
),
migrations.AddField(
model_name='projectpage',
name='body',
field=wagtail.core.fields.StreamField([('Image', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.CharBlock(help_text='Not displayed, used internally', required=False)), ('on_home', wagtail.core.blocks.BooleanBlock(help_text="Defines whether this block be displayed on the homepage. Only the first 'homepage' block will be visible.")), ('on_list', wagtail.core.blocks.BooleanBlock(help_text='Defines whether this block be displayed on the project listing page.')), ('on_detail', wagtail.core.blocks.BooleanBlock(help_text='Defines whether this block will be displayed on the project detail page.')), ('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'superscript', 'link', 'document_link'], required=False))])), ('Quote', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.CharBlock(help_text='Not displayed, used internally', required=False)), ('on_home', wagtail.core.blocks.BooleanBlock(help_text="Defines whether this block be displayed on the homepage. Only the first 'homepage' block will be visible.")), ('on_list', wagtail.core.blocks.BooleanBlock(help_text='Defines whether this block be displayed on the project listing page.')), ('on_detail', wagtail.core.blocks.BooleanBlock(help_text='Defines whether this block will be displayed on the project detail page.')), ('quote', wagtail.core.blocks.CharBlock()), ('attribution', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'superscript', 'link', 'document_link'], required=False))])), ('FreeText', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.CharBlock(help_text='Not displayed, used internally', required=False)), ('on_home', wagtail.core.blocks.BooleanBlock(help_text="Defines whether this block be displayed on the homepage. Only the first 'homepage' block will be visible.")), ('on_list', wagtail.core.blocks.BooleanBlock(help_text='Defines whether this block be displayed on the project listing page.')), ('on_detail', wagtail.core.blocks.BooleanBlock(help_text='Defines whether this block will be displayed on the project detail page.')), ('body', wagtail.core.blocks.StreamBlock([('heading', projects.models.HeadingBlock()), ('text', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'link', 'document_link', 'embed', 'superscript'])), ('quote', wagtail.core.blocks.BlockQuoteBlock()), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'superscript', 'link', 'document_link'], required=False))])), ('plan', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'superscript', 'link', 'document_link'], required=False))])), ('gallery', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=False)), ('images', wagtail.core.blocks.StreamBlock([('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'superscript', 'link', 'document_link'], required=False))])), ('plan', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'superscript', 'link', 'document_link'], required=False))]))])), ('caption', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'superscript', 'link', 'document_link'], required=False))])), ('datablock', wagtail.core.blocks.StreamBlock([('dataheader', wagtail.core.blocks.CharBlock()), ('datarow', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.ChoiceBlock(choices=projects.models.get_project_datablock_choices, classname='field-col col6', form_classname='field-col col6')), ('value', wagtail.core.blocks.CharBlock(classname='field-col col6', form_classname='field-col col6'))]))]))]))]))], default=''),
preserve_default=False,
),
migrations.AddField(
model_name='projectpage',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='projectpage',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AlterField(
model_name='project',
name='body',
field=wagtail.core.fields.StreamField([('heading', projects.models.HeadingBlock()), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('quote', wagtail.core.blocks.BlockQuoteBlock()), ('quotesnippet', wagtail.snippets.blocks.SnippetChooserBlock(projects.models.Quote)), ('datablock', wagtail.core.blocks.StreamBlock([('datarow', wagtail.core.blocks.StructBlock([('name', wagtail.core.blocks.ChoiceBlock(choices=projects.models.get_project_datablock_choices, classname='field-col col6', form_classname='field-col col6')), ('value', wagtail.core.blocks.CharBlock(classname='field-col col6', form_classname='field-col col6'))])), ('dataheader', wagtail.core.blocks.CharBlock())], icon='table', template='projects/blocks/datablock.html')), ('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock()), ('gallery', wagtail.core.blocks.StreamBlock([('plan', wagtail.images.blocks.ImageChooserBlock()), ('picture', wagtail.images.blocks.ImageChooserBlock())]))]),
),
]
......@@ -15,16 +15,21 @@ from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, StreamFieldPane
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index
from wagtail.snippets.blocks import SnippetChooserBlock
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail.snippets.models import register_snippet
RICHTEXTFIELD_INLINE_FEATURE_SET = ['bold', 'italic', 'superscript', 'link', 'document_link']
class HeadingBlock(blocks.CharBlock):
class Meta:
template = 'nord/snippets/header.html'
template = 'projects/blocks/heading.html'
classname = 'full title'
icon = 'title'
class DataBlock(blocks.StructBlock):
name = blocks.ChoiceBlock(choices=(
(0, 'Status'),
def get_project_datablock_choices():
return ((0, 'Status'),
(1, 'Procedure'),
(2, 'Area'),
(3, 'Budget'),
......@@ -59,10 +64,12 @@ class DataBlock(blocks.StructBlock):
(32, 'Adjudication budget'),
(33, 'Final budget'),
(34, 'Study start'),
(35, 'Expeted delivery date'),
(36, 'Delivery date')
), classname='field-col col6', form_classname='field-col col6')
(35, 'Expected delivery date'),
(36, 'Delivery date'))
class DataBlock(blocks.StructBlock):
name = blocks.ChoiceBlock(choices=get_project_datablock_choices, classname='field-col col6', form_classname='field-col col6')
value = blocks.CharBlock(classname='field-col col6', form_classname='field-col col6')
class Meta:
......@@ -70,18 +77,61 @@ class DataBlock(blocks.StructBlock):
form_classname = 'field_row'
class ProjectPage(Page):
location = models.CharField(max_length=250, blank=True)
short_description = RichTextField(features=['bold', 'italic', 'link'])
@register_snippet
class Quote(index.Indexed, models.Model):
quote = RichTextField(features=['bold', 'italic'])
attribution = models.CharField(blank=True, max_length=250)
panels = [
FieldPanel('quote'),
FieldPanel('attribution')
]
search_fields = [
index.SearchField('quote'),
index.SearchField('attribution')
]
def __str__ (self):
return self.quote
@register_snippet
class Image (index.Indexed, models.Model):
image = models.ForeignKey(
'wagtailimages.Image',
on_delete=models.PROTECT,
related_name='+'
)
caption = RichTextField(features=RICHTEXTFIELD_INLINE_FEATURE_SET, blank=True)
panels = [
ImageChooserPanel('image'),
FieldPanel('caption')
]
search_fields = [
index.SearchField('caption')
]
@register_snippet
class Project(index.Indexed, models.Model):
title = models.CharField(max_length=250)
short_description = RichTextField(features=RICHTEXTFIELD_INLINE_FEATURE_SET)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
body = StreamField([
('heading', HeadingBlock()),
('paragraph', blocks.RichTextBlock()),
('quote', blocks.BlockQuoteBlock()),
('quotesnippet', SnippetChooserBlock(Quote)),
('datablock', blocks.StreamBlock([
('datarow', DataBlock()),
('dataheader', blocks.CharBlock()
)], icon='table')),
)], icon='table', template='projects/blocks/datablock.html')),
('plan', ImageChooserBlock()),
('picture', ImageChooserBlock()),
('gallery', blocks.StreamBlock([
......@@ -90,19 +140,133 @@ class ProjectPage(Page):
]))
])
search_fields = Page.search_fields + [
search_fields = [
index.SearchField('title'),
index.SearchField('short_description'),
index.SearchField('body'),
]
content_panels = Page.content_panels + [
panels = [
FieldPanel('title'),
FieldPanel('location'),
FieldPanel('short_description'),
StreamFieldPanel('body')
]
def __str__ (self):
if self.updated_at:
return '{} ({} last edit: {})'.format(self.title, self.created_at.strftime('%d-%m-%Y'), self.updated_at.strftime('%d-%m-%Y'))
else:
return '{} ({})'.format(self.title, self.created_at.strftime('%d-%m-%Y'))
class ProjectBaseBlock (blocks.StructBlock):
name = blocks.CharBlock(required=False, help_text="Not displayed, used internally")
on_home = blocks.BooleanBlock(help_text="Defines whether this block be displayed on the homepage. Only the first 'homepage' block will be visible.")
on_list = blocks.BooleanBlock(help_text="Defines whether this block be displayed on the project listing page.")
on_detail = blocks.BooleanBlock(help_text="Defines whether this block will be displayed on the project detail page.")
class ProjectImageBlock (ProjectBaseBlock):
image = ImageChooserBlock()
caption = blocks.RichTextBlock(required=False, features=RICHTEXTFIELD_INLINE_FEATURE_SET)
class ProjectQuoteBlock (ProjectBaseBlock):