Skip to content

Commit

Permalink
upgrade for wagtail 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnarTumi committed Oct 4, 2023
1 parent 6b50959 commit a8774f1
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 21 deletions.
6 changes: 3 additions & 3 deletions wagtailtables/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from django.conf import settings
from django.utils.functional import cached_property

from wagtail.core.telepath import register
from wagtail.telepath import register
from wagtail import VERSION

# Backwards compatibility
if VERSION[0] < 3:
from wagtail.core.blocks.struct_block import StructBlockAdapter
from wagtail.core.blocks import (BooleanBlock, CharBlock, ChoiceBlock,
from wagtail.blocks.struct_block import StructBlockAdapter
from wagtail.blocks import (BooleanBlock, CharBlock, ChoiceBlock,
StructBlock, TextBlock)
else:
from wagtail.blocks.struct_block import StructBlockAdapter
Expand Down
11 changes: 10 additions & 1 deletion wagtailtables/static/wagtailtables/js/table-dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ class TableDefinition extends window.wagtailStreamField.blocks.StructBlockDefini
dataSetField.value = "{\"data\": "+JSON.stringify(spread.getData())+", \"style\": "+JSON.stringify(spread.getStyle())+"}";
}
}

let merge_cells = function(table, a, b, c){
debugger
}

let toolbar = this.meta.toolbar
let merge = {type: 'i', content: 'table_rows', onclick: merge_cells}
toolbar.push(merge)

var options = {
tableOverflow: true,
tableWidth: "100%",
columnSorting: false,
defaultColAlign: 'left',
defaultColWidth: 200,
toolbar: this.meta.toolbar,
toolbar: toolbar,
onevent: changed,
}

Expand Down
4 changes: 2 additions & 2 deletions wagtailtables_demo/home/blocks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sre_constants import CHARSET

from wagtail.core.blocks import (CharBlock, ChoiceBlock, RichTextBlock,
from wagtail.blocks import (CharBlock, ChoiceBlock, RichTextBlock,
StreamBlock, StructBlock, TextBlock)
from wagtail.embeds.blocks import EmbedBlock
from wagtail.images.blocks import ImageChooserBlock
Expand All @@ -19,4 +19,4 @@

class ContentBlocks(StreamBlock):
title = CharBlock()
table_block = TableBlock(toolbar=TOOLBAR)
table_block = TableBlock()
6 changes: 3 additions & 3 deletions wagtailtables_demo/home/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.blocks
import wagtail.fields
import wagtailtables.blocks


Expand All @@ -20,7 +20,7 @@ class Migration(migrations.Migration):
name='HomePage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('body', wagtail.core.fields.StreamField([('title', wagtail.core.blocks.CharBlock()), ('table_block', wagtail.core.blocks.StructBlock([('table_data', wagtail.core.blocks.TextBlock(default='[]')), ('caption', wagtail.core.blocks.CharBlock(required=False)), ('header_row', wagtail.core.blocks.BooleanBlock(required=False)), ('header_col', wagtail.core.blocks.BooleanBlock(required=False)), ('table_type', wagtail.core.blocks.ChoiceBlock(choices=wagtailtables.blocks.get_choices))]))])),
('body', wagtail.fields.StreamField([('title', wagtail.blocks.CharBlock()), ('table_block', wagtail.blocks.StructBlock([('table_data', wagtail.blocks.TextBlock(default='[]')), ('caption', wagtail.blocks.CharBlock(required=False)), ('header_row', wagtail.blocks.BooleanBlock(required=False)), ('header_col', wagtail.blocks.BooleanBlock(required=False)), ('table_type', wagtail.blocks.ChoiceBlock(choices=wagtailtables.blocks.get_choices))]))])),
],
options={
'abstract': False,
Expand Down
14 changes: 5 additions & 9 deletions wagtailtables_demo/home/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
from django.db import models
from wagtail.admin.edit_handlers import (FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel,
PageChooserPanel, StreamFieldPanel)
from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
from wagtail.models import Page

from .blocks import ContentBlocks


class HomePage(Page):
body = StreamField(ContentBlocks())
body = StreamField(ContentBlocks(), use_json_field=True)

content_panels = Page.content_panels + [
StreamFieldPanel('body'),
FieldPanel('body'),
]
2 changes: 1 addition & 1 deletion wagtailtables_demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django>=4.0,<4.1
wagtail>=2.16,<2.17
wagtail==5.1.2
dj-database-url==0.4.1
psycopg2-binary>=2.7,<3.0
debugpy==1.5.1
2 changes: 1 addition & 1 deletion wagtailtables_demo/wagtailtables_demo/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail',

'modelcluster',
'taggit',
Expand Down
2 changes: 1 addition & 1 deletion wagtailtables_demo/wagtailtables_demo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib import admin
from django.urls import include, path
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls

urlpatterns = [
Expand Down

0 comments on commit a8774f1

Please sign in to comment.