Skip to content

Commit

Permalink
upgrade to wagtail 3
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk authored and philli-m committed Jun 16, 2022
1 parent 30001d3 commit 1b620a1
Show file tree
Hide file tree
Showing 32 changed files with 284 additions and 132 deletions.
2 changes: 1 addition & 1 deletion adhocracy-plus/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail',
'modelcluster',
'taggit',
'apps.cms.pages',
Expand Down
2 changes: 1 addition & 1 deletion adhocracy-plus/config/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
pass


BASE_URL = 'http://localhost:8004'
WAGTAILADMIN_BASE_URL = 'http://localhost:8004'
CAPTCHA_URL = 'https://captcheck.netsyms.com/api.php'
SITE_ID = 1

Expand Down
2 changes: 1 addition & 1 deletion adhocracy-plus/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,5 @@
# generic patterns at the very end
urlpatterns += [
re_path(r'', include('apps.organisations.urls')),
re_path(r'', include('wagtail.core.urls')),
re_path(r'', include('wagtail.urls')),
]
2 changes: 1 addition & 1 deletion apps/actions/blocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.utils.translation import gettext_lazy as _
from wagtail.core import blocks
from wagtail import blocks

from adhocracy4.actions.models import Action

Expand Down
2 changes: 1 addition & 1 deletion apps/cms/blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.core import blocks
from wagtail import blocks
from wagtail.documents.blocks import DocumentChooserBlock
from wagtail.images.blocks import ImageChooserBlock

Expand Down
6 changes: 3 additions & 3 deletions apps/cms/contacts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
import wagtail.core.fields
import wagtail.fields


class Migration(migrations.Migration):
Expand All @@ -25,8 +25,8 @@ class Migration(migrations.Migration):
('subject', models.CharField(blank=True, max_length=255, verbose_name='subject')),
('header_de', models.CharField(blank=True, max_length=500, verbose_name='Header')),
('header_en', models.CharField(blank=True, max_length=500, verbose_name='Header')),
('intro_en', wagtail.core.fields.RichTextField(blank=True)),
('intro_de', wagtail.core.fields.RichTextField(blank=True)),
('intro_en', wagtail.fields.RichTextField(blank=True)),
('intro_de', wagtail.fields.RichTextField(blank=True)),
('thank_you_text_en', models.TextField(blank=True)),
('thank_you_text_de', models.TextField(blank=True)),
('contact_person_name', models.CharField(blank=True, max_length=100)),
Expand Down
40 changes: 40 additions & 0 deletions apps/cms/contacts/migrations/0003_auto_20220614_1427.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 3.2.13 on 2022-06-14 12:27

import django.core.serializers.json
from django.db import migrations, models
import wagtail.contrib.forms.models


class Migration(migrations.Migration):

dependencies = [
('a4_candy_cms_contacts', '0002_new_wagtail_fields'),
]

operations = [
migrations.AlterField(
model_name='customformsubmission',
name='form_data',
field=models.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder),
),
migrations.AlterField(
model_name='formfield',
name='choices',
field=models.TextField(blank=True, help_text='Comma or new line separated list of choices. Only applicable in checkboxes, radio and dropdown.', verbose_name='choices'),
),
migrations.AlterField(
model_name='formfield',
name='default_value',
field=models.TextField(blank=True, help_text='Default value. Comma or new line separated values supported for checkboxes.', verbose_name='default value'),
),
migrations.AlterField(
model_name='formpage',
name='from_address',
field=models.EmailField(blank=True, max_length=255, verbose_name='from address'),
),
migrations.AlterField(
model_name='formpage',
name='to_address',
field=models.CharField(blank=True, help_text='Optional - form submissions will be emailed to these addresses. Separate multiple addresses by comma.', max_length=255, validators=[wagtail.contrib.forms.models.validate_to_address], verbose_name='to address'),
),
]
15 changes: 7 additions & 8 deletions apps/cms/contacts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
from django.shortcuts import redirect
from django.utils.translation import gettext_lazy as _
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.admin.edit_handlers import FieldRowPanel
from wagtail.admin.edit_handlers import MultiFieldPanel
from wagtail.admin.edit_handlers import ObjectList
from wagtail.admin.edit_handlers import TabbedInterface
from wagtail.admin.panels import FieldPanel
from wagtail.admin.panels import FieldRowPanel
from wagtail.admin.panels import MultiFieldPanel
from wagtail.admin.panels import ObjectList
from wagtail.admin.panels import TabbedInterface
from wagtail.contrib.forms.forms import FormBuilder
from wagtail.contrib.forms.models import AbstractEmailForm
from wagtail.contrib.forms.models import AbstractFormField
from wagtail.contrib.forms.models import AbstractFormSubmission
from wagtail.core.fields import RichTextField
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.fields import RichTextField

from apps.captcha.fields import CaptcheckCaptchaField
from apps.cms.emails import AnswerToContactFormEmail
Expand Down Expand Up @@ -200,7 +199,7 @@ def get_form_fields(self):
MultiFieldPanel([
FieldRowPanel([
FieldPanel('contact_person_name', classname="col6"),
ImageChooserPanel('contact_person_image', classname="col6"),
FieldPanel('contact_person_image', classname="col6"),
]),
], "Contact Person"),

Expand Down
4 changes: 2 additions & 2 deletions apps/cms/images/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import wagtail.core.models
import wagtail.models
import wagtail.images.models
import wagtail.search.index

Expand Down Expand Up @@ -37,7 +37,7 @@ class Migration(migrations.Migration):
('file_hash', models.CharField(blank=True, editable=False, max_length=40)),
('caption_en', models.CharField(blank=True, max_length=255)),
('caption_de', models.CharField(blank=True, max_length=255)),
('collection', models.ForeignKey(default=wagtail.core.models.get_root_collection_id, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailcore.Collection', verbose_name='collection')),
('collection', models.ForeignKey(default=wagtail.models.get_root_collection_id, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailcore.Collection', verbose_name='collection')),
('tags', taggit.managers.TaggableManager(blank=True, help_text=None, through='taggit.TaggedItem', to='taggit.Tag', verbose_name='tags')),
('uploaded_by_user', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='uploaded by user')),
],
Expand Down
18 changes: 18 additions & 0 deletions apps/cms/images/migrations/0002_alter_customimage_file_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2022-06-14 12:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('a4_candy_cms_images', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='customimage',
name='file_hash',
field=models.CharField(blank=True, db_index=True, editable=False, max_length=40),
),
]
2 changes: 1 addition & 1 deletion apps/cms/news/blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.core import blocks
from wagtail import blocks


class NewsBlock(blocks.StructBlock):
Expand Down
8 changes: 4 additions & 4 deletions apps/cms/news/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


class Migration(migrations.Migration):
Expand Down Expand Up @@ -39,8 +39,8 @@ class Migration(migrations.Migration):
('author', models.CharField(blank=True, max_length=255, verbose_name='Author Name')),
('create_date', models.DateTimeField(auto_now_add=True)),
('update_date', models.DateTimeField(auto_now=True)),
('body_streamfield_de', wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('html', wagtail.core.blocks.RawHTMLBlock())], blank=True)),
('body_streamfield_en', wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('html', wagtail.core.blocks.RawHTMLBlock())], blank=True)),
('body_streamfield_de', wagtail.fields.StreamField([('paragraph', wagtail.blocks.RichTextBlock()), ('html', wagtail.blocks.RawHTMLBlock())], blank=True)),
('body_streamfield_en', wagtail.fields.StreamField([('paragraph', wagtail.blocks.RichTextBlock()), ('html', wagtail.blocks.RawHTMLBlock())], blank=True)),
('image', models.ForeignKey(blank=True, help_text='The Image that is shown on the news item page and the news index page', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='a4_candy_cms_images.CustomImage', verbose_name='News Header Image')),
],
options={
Expand Down
25 changes: 25 additions & 0 deletions apps/cms/news/migrations/0002_auto_20220614_1427.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.13 on 2022-06-14 12:27

from django.db import migrations
import wagtail.blocks
import wagtail.fields


class Migration(migrations.Migration):

dependencies = [
('a4_candy_cms_news', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='newspage',
name='body_streamfield_de',
field=wagtail.fields.StreamField([('paragraph', wagtail.blocks.RichTextBlock()), ('html', wagtail.blocks.RawHTMLBlock())], blank=True, use_json_field=True),
),
migrations.AlterField(
model_name='newspage',
name='body_streamfield_en',
field=wagtail.fields.StreamField([('paragraph', wagtail.blocks.RichTextBlock()), ('html', wagtail.blocks.RawHTMLBlock())], blank=True, use_json_field=True),
),
]
24 changes: 11 additions & 13 deletions apps/cms/news/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
from django.core.paginator import Paginator
from django.db import models
from django.http import Http404
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.admin.edit_handlers import ObjectList
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.admin.edit_handlers import TabbedInterface
from wagtail.core import blocks
from wagtail.core import fields
from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail import blocks
from wagtail import fields
from wagtail.admin.panels import FieldPanel
from wagtail.admin.panels import ObjectList
from wagtail.admin.panels import TabbedInterface
from wagtail.models import Page

from apps.contrib.translations import TranslatedField

Expand Down Expand Up @@ -97,12 +95,12 @@ class NewsPage(Page):
body_streamfield_de = fields.StreamField([
('paragraph', blocks.RichTextBlock()),
('html', blocks.RawHTMLBlock())
], blank=True)
], use_json_field=True, blank=True)

body_streamfield_en = fields.StreamField([
('paragraph', blocks.RichTextBlock()),
('html', blocks.RawHTMLBlock())
], blank=True)
], use_json_field=True, blank=True)

subtitle = TranslatedField(
'title_de',
Expand All @@ -122,18 +120,18 @@ class NewsPage(Page):
en_content_panels = [
FieldPanel('title_en'),
FieldPanel('teaser_en'),
StreamFieldPanel('body_streamfield_en')
FieldPanel('body_streamfield_en')
]

de_content_panels = [
FieldPanel('title_de'),
FieldPanel('teaser_de'),
StreamFieldPanel('body_streamfield_de')
FieldPanel('body_streamfield_de')
]

common_panels = [
FieldPanel('title'),
ImageChooserPanel('image'),
FieldPanel('image'),
FieldPanel('author'),
FieldPanel('slug')
]
Expand Down
Loading

0 comments on commit 1b620a1

Please sign in to comment.