Skip to content

Commit 1ab34d8

Browse files
authored
Merge pull request #1 from overcastsoftware/wt4
backwards compatible fix for wagtailtables
2 parents 0fa05b5 + 1502c4a commit 1ab34d8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

wagtailtables/blocks.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
from django import forms
33
from django.conf import settings
44
from django.utils.functional import cached_property
5-
from wagtail.core.blocks import (BooleanBlock, CharBlock, ChoiceBlock,
6-
StructBlock, TextBlock)
7-
from wagtail.core.blocks.struct_block import StructBlockAdapter
5+
86
from wagtail.core.telepath import register
7+
from wagtail import VERSION
98

9+
# Backwards compatibility
10+
if VERSION[0] < 3:
11+
from wagtail.core.blocks.struct_block import StructBlockAdapter
12+
from wagtail.core.blocks import (BooleanBlock, CharBlock, ChoiceBlock,
13+
StructBlock, TextBlock)
14+
else:
15+
from wagtail.blocks.struct_block import StructBlockAdapter
16+
from wagtail.blocks import (BooleanBlock, CharBlock, ChoiceBlock,
17+
StructBlock, TextBlock)
1018

1119
def get_choices():
1220
default_choices = (
@@ -36,8 +44,6 @@ class Meta:
3644
label = 'Table Block'
3745
template = 'wagtailtables/table_block.html'
3846

39-
40-
4147

4248
class TableAdapter(StructBlockAdapter):
4349
js_constructor = 'streams.blocks.TableBlock'

0 commit comments

Comments
 (0)