Commit 48742a5c authored by gijs's avatar gijs
Browse files

Ugly solution for datarow template.

parent 20aa3080
......@@ -29,7 +29,7 @@ class HeadingBlock(blocks.CharBlock):
def get_project_datablock_choices():
return ((0, 'Status'),
return [(0, 'Status'),
(1, 'Procedure'),
(2, 'Area'),
(3, 'Budget'),
......@@ -65,7 +65,7 @@ def get_project_datablock_choices():
(33, 'Final budget'),
(34, 'Study start'),
(35, 'Expected delivery date'),
(36, 'Delivery date'))
(36, 'Delivery date')]
class DataBlock(blocks.StructBlock):
......@@ -75,6 +75,7 @@ class DataBlock(blocks.StructBlock):
class Meta:
icon = 'horizontalrule'
form_classname = 'field_row'
template = 'projects/blocks/project-stream-datablock-datarow.html'
@register_snippet
......@@ -115,50 +116,6 @@ class Image (index.Indexed, models.Model):
]
# 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', template='projects/blocks/datablock.html')),
# ('plan', ImageChooserBlock()),
# ('picture', ImageChooserBlock()),
# ('gallery', blocks.StreamBlock([
# ('plan', ImageChooserBlock()),
# ('picture', ImageChooserBlock())
# ]))
# ])
# search_fields = [
# index.SearchField('title'),
# index.SearchField('short_description'),
# index.SearchField('body'),
# ]
# 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")
......@@ -166,6 +123,7 @@ class ProjectBaseBlock (blocks.StructBlock):
on_list = blocks.BooleanBlock(required=False, help_text="Defines whether this block be displayed on the project listing page.")
on_detail = blocks.BooleanBlock(required=False, 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)
......@@ -175,7 +133,6 @@ class ProjectImageBlock (ProjectBaseBlock):
icon = 'image'
classname= 'collapsible'
form_classname= 'collapsible'
class ProjectQuoteBlock (ProjectBaseBlock):
# Todo change quote to RichTextBlock.
quote = blocks.RichTextBlock(features=RICHTEXTFIELD_INLINE_FEATURE_SET)
......@@ -193,6 +150,7 @@ class ProjectStreamImageBlock(blocks.StructBlock):
class Meta:
icon = 'image'
template = 'projects/blocks/project-stream-image.html'
class ProjectStreamPlanBlock(ProjectStreamImageBlock):
pass
......@@ -204,14 +162,15 @@ class ProjectStreamGalleryBlock(blocks.StructBlock):
class Meta:
icon = 'folder'
template = 'projects/blocks/project-stream-gallery.html'
class ProjectStreamDataBlock(blocks.StreamBlock):
dataheader = blocks.CharBlock()
dataheader = blocks.CharBlock(template='projects/blocks/project-stream-datablock-dataheader.html')
datarow = DataBlock()
class Meta:
icon='table'
templates = 'projects/block/databloc.html'
templates = 'projects/block/project-stream-datablock.html'
class ProjectStreamBlock (ProjectBaseBlock):
body = blocks.StreamBlock([
......
{% for child in value %}
?
{{ child }}
{% endfor%}
\ No newline at end of file
{% load wagtailcore_tags wagtailimages_tags %}
<figure class="block-project block-project--image">
{% image value.image %}
{% image value.image width-800 %}
{% if value.caption %}
<figcaption>
{{ value.caption|richtext }}
......
<dt class="header">{{ value }}</dt>
\ No newline at end of file
{% load wagtailcore_tags project_tags %}
<dt>{{ value.name|get_datablock_datarow_display }}<dt>
<dd>{{ value.value }}</dd>
\ No newline at end of file
{% load wagtailcore_tags %}
<dl class="project--block project--block--datablock">
{% for datarow in datablock %}
{% include_block datarow %}
{% endforor%}
</dl>
\ No newline at end of file
{% load wagtailcore_tags wagtailimages_tags %}
<section class="block-project block-project--stream--gallery">
{% if value.title %}
<h2>{{ value.title }}</h2>
{% endif %}
<section class="block-project--stream--gallery--images">
{% for gallery_image in value.images %}
{% include_block gallery_image %}
{% endfor %}
</section>
{% if value.caption %}
<figcaption>
{{ value.caption|richtext }}
</figcaption>
{% endif %}
</section>
\ No newline at end of file
{% load wagtailcore_tags wagtailimages_tags %}
<figure class="block-project block-project--stream--image">
{% image value.image width-800 %}
{% if value.caption %}
<figcaption>
{{ value.caption|richtext }}
</figcaption>
{% endif %}
</figure>
\ No newline at end of file
from projects.models import get_project_datablock_choices
from django import template
register = template.Library()
@register.filter
def get_datablock_datarow_display (value):
choices = get_project_datablock_choices()
return dict(choices)[int(value)]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment