From 31e35053398cc66a0c316df175b1181300625918 Mon Sep 17 00:00:00 2001 From: Jonathan DeMasi Date: Tue, 10 Mar 2020 11:23:49 -0600 Subject: tables working --- blog/migrations/0010_auto_20200310_1719.py | 24 +++++++++++ blog/models.py | 3 ++ blog/templates/blog/table_template.html | 48 +++++++++++++++++++++ jthanio/settings/base.py | 1 + ...0233_1659x984_sc.2e16d0ba.fill-900x300-c100.png | Bin 0 -> 116180 bytes ...020-02-11-100233_1659x984_scrot.max-165x165.png | Bin 0 -> 10505 bytes .../2020-02-11-100233_1659x984_scrot.png | Bin 0 -> 152549 bytes 7 files changed, 76 insertions(+) create mode 100644 blog/migrations/0010_auto_20200310_1719.py create mode 100644 blog/templates/blog/table_template.html create mode 100644 media/images/2020-02-11-100233_1659x984_sc.2e16d0ba.fill-900x300-c100.png create mode 100644 media/images/2020-02-11-100233_1659x984_scrot.max-165x165.png create mode 100644 media/original_images/2020-02-11-100233_1659x984_scrot.png diff --git a/blog/migrations/0010_auto_20200310_1719.py b/blog/migrations/0010_auto_20200310_1719.py new file mode 100644 index 0000000..b4c8b97 --- /dev/null +++ b/blog/migrations/0010_auto_20200310_1719.py @@ -0,0 +1,24 @@ +# Generated by Django 3.0.4 on 2020-03-10 17:19 + +from django.db import migrations +import wagtail.contrib.table_block.blocks +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.documents.blocks +import wagtail.embeds.blocks +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0009_auto_20200306_0713'), + ] + + operations = [ + migrations.AlterField( + model_name='blogpost', + name='body', + field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('page', wagtail.core.blocks.PageChooserBlock()), ('document', wagtail.documents.blocks.DocumentChooserBlock()), ('media', wagtail.embeds.blocks.EmbedBlock()), ('html', wagtail.core.blocks.RawHTMLBlock(label='Raw HTML')), ('code', wagtail.core.blocks.StructBlock([('language', wagtail.core.blocks.ChoiceBlock(choices=[('bash', 'Bash/Shell'), ('css', 'CSS'), ('diff', 'diff'), ('html', 'HTML'), ('javascript', 'Javascript'), ('json', 'JSON'), ('python', 'Python'), ('scss', 'SCSS'), ('yaml', 'YAML')], help_text='Coding language', identifier='language', label='Language')), ('code', wagtail.core.blocks.TextBlock(identifier='code', label='Code'))], label='Code')), ('table', wagtail.contrib.table_block.blocks.TableBlock(template='blog/table_template.html'))]), + ), + ] diff --git a/blog/models.py b/blog/models.py index e34ca58..03667c5 100644 --- a/blog/models.py +++ b/blog/models.py @@ -14,6 +14,7 @@ from wagtailcodeblock.blocks import CodeBlock from modelcluster.fields import ParentalKey, ParentalManyToManyField from modelcluster.contrib.taggit import ClusterTaggableManager +from wagtail.contrib.table_block.blocks import TableBlock from taggit.models import TaggedItemBase from wagtail.snippets.models import register_snippet @@ -68,6 +69,8 @@ class BlogPost(Page): ('media', EmbedBlock()), ('html', blocks.RawHTMLBlock(label='Raw HTML')), ('code', CodeBlock(label='Code')), + ('table', TableBlock(template="blog/table_template.html")), + ]) tags = ClusterTaggableManager(through=BlogPostTag, blank=True) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) diff --git a/blog/templates/blog/table_template.html b/blog/templates/blog/table_template.html new file mode 100644 index 0000000..53081ac --- /dev/null +++ b/blog/templates/blog/table_template.html @@ -0,0 +1,48 @@ + + {% if table_header %} + + + {% for column in table_header %} + + {% endfor %} + + + {% endif %} + + {% for row in data %} + + {% for column in row %} + {% if first_col_is_header and forloop.first %} + + {% else %} + + {% endif %} + {% endfor %} + + {% endfor %} + +
+ {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} + {% endif %} + {% endif %} +
+ {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} + {% endif %} + {% endif %} + + {% if column.strip %} + {% if html_renderer %} + {{ column.strip|safe|linebreaksbr }} + {% else %} + {{ column.strip|linebreaksbr }} + {% endif %} + {% endif %} +
diff --git a/jthanio/settings/base.py b/jthanio/settings/base.py index 466fd1d..2dc5b44 100644 --- a/jthanio/settings/base.py +++ b/jthanio/settings/base.py @@ -28,6 +28,7 @@ INSTALLED_APPS = [ 'blog', 'search', 'wagtailcodeblock', + 'wagtail.contrib.table_block', 'wagtail.contrib.forms', 'wagtail.contrib.redirects', 'wagtail.embeds', diff --git a/media/images/2020-02-11-100233_1659x984_sc.2e16d0ba.fill-900x300-c100.png b/media/images/2020-02-11-100233_1659x984_sc.2e16d0ba.fill-900x300-c100.png new file mode 100644 index 0000000..1befa8e Binary files /dev/null and b/media/images/2020-02-11-100233_1659x984_sc.2e16d0ba.fill-900x300-c100.png differ diff --git a/media/images/2020-02-11-100233_1659x984_scrot.max-165x165.png b/media/images/2020-02-11-100233_1659x984_scrot.max-165x165.png new file mode 100644 index 0000000..7c0b3dc Binary files /dev/null and b/media/images/2020-02-11-100233_1659x984_scrot.max-165x165.png differ diff --git a/media/original_images/2020-02-11-100233_1659x984_scrot.png b/media/original_images/2020-02-11-100233_1659x984_scrot.png new file mode 100644 index 0000000..3348315 Binary files /dev/null and b/media/original_images/2020-02-11-100233_1659x984_scrot.png differ -- cgit v1.2.3