Skip to content

Commit

Permalink
WIP - Wagtail 4.0.4 upgrade (#1480)
Browse files Browse the repository at this point in the history
* Django 4.1.7 changes

* last edits for upgrade

* Update requirements

* Removed references to ImageChooserPanel

* Fixed small bug in book index page

* Removed wagtail.core

* Updated postgres version from 10 to 13
  • Loading branch information
edwoodward authored Oct 20, 2023
1 parent e9ba3ac commit 80e330e
Show file tree
Hide file tree
Showing 88 changed files with 644 additions and 393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:10
image: postgres:13
ports:
- 5432:5432
options: >-
Expand Down
4 changes: 2 additions & 2 deletions allies/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 wagtail.core.fields
import wagtail.fields


class Migration(migrations.Migration):
Expand All @@ -22,7 +22,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ally_category', models.CharField(choices=[('OH', 'Online Homework'), ('AC', 'Adaptive Courseware'), ('CT', 'Customized Tools')], max_length=2)),
('heading', models.CharField(max_length=255)),
('description', wagtail.core.fields.RichTextField()),
('description', wagtail.fields.RichTextField()),
('link_url', models.URLField(blank=True, help_text='Call to Action Link')),
('link_text', models.CharField(help_text='Call to Action Text', max_length=255)),
('logo', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
Expand Down
4 changes: 2 additions & 2 deletions allies/migrations/0002_auto_20160222_1359.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand All @@ -21,7 +21,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='ally',
name='long_description',
field=wagtail.core.fields.RichTextField(default=''),
field=wagtail.fields.RichTextField(default=''),
preserve_default=False,
),
]
6 changes: 3 additions & 3 deletions allies/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import (FieldPanel, InlinePanel,
from wagtail.admin.panels import (FieldPanel, InlinePanel,
MultiFieldPanel)
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page
from wagtail.fields import RichTextField
from wagtail.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel

from openstax.functions import build_image_url
Expand Down
9 changes: 6 additions & 3 deletions books/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.contrib.postgres.fields import ArrayField
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.admin.edit_handlers import (FieldPanel,
from wagtail.admin.panels import (FieldPanel,
InlinePanel,
PageChooserPanel,
StreamFieldPanel)
Expand All @@ -22,7 +22,7 @@
from wagtail.snippets.blocks import SnippetChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail.admin.edit_handlers import TabbedInterface, ObjectList
from wagtail.admin.panels import TabbedInterface, ObjectList
from wagtail.api import APIField
from wagtail.snippets.models import register_snippet
from wagtail.models import Site
Expand Down Expand Up @@ -503,7 +503,10 @@ class Book(Page):
help_text='The book cover to be shown on the website.'
)
def get_cover_url(self):
return build_document_url(self.cover.url)
if self.cover:
return build_document_url(self.cover.url)
else:
return ''
cover_url = property(get_cover_url)

title_image = models.ForeignKey(
Expand Down
2 changes: 1 addition & 1 deletion global_settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default_app_config = 'global_settings.apps.GlobalSettingsConfig'
#default_app_config = 'global_settings.apps.GlobalSettingsConfig'
2 changes: 2 additions & 0 deletions global_settings/apps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.apps import AppConfig


class GlobalSettingsConfig(AppConfig):
name = 'global_settings'
verbose_name = 'global_settings'
default = True

def ready(self):
import global_settings.signals # noqa
Expand Down
4 changes: 2 additions & 2 deletions global_settings/migrations/0009_auto_20170912_1337.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import unicode_literals

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


class Migration(migrations.Migration):
Expand All @@ -16,6 +16,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='footer',
name='copyright',
field=wagtail.core.fields.RichTextField(),
field=wagtail.fields.RichTextField(),
),
]
10 changes: 5 additions & 5 deletions global_settings/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.db import models
from wagtail.contrib.settings.models import BaseSetting, register_setting
from wagtail.contrib.settings.models import BaseSiteSetting, register_setting


@register_setting(icon='doc-empty')
class StickyNote(BaseSetting):
class StickyNote(BaseSiteSetting):
start = models.DateTimeField(null=True, help_text="Set the start date to override the content of the Give Sticky. Set the header and body below to change.")
expires = models.DateTimeField(null=True, help_text="Set the date to expire overriding the content of the Give Sticky.")
show_popup = models.BooleanField(default=False, help_text="Replaces the top banner with a popup, start and expire dates still control timing.")
Expand All @@ -19,7 +19,7 @@ class Meta:


@register_setting(icon='collapse-down')
class Footer(BaseSetting):
class Footer(BaseSiteSetting):
supporters = models.TextField()
copyright = models.TextField()
ap_statement = models.TextField()
Expand All @@ -31,15 +31,15 @@ class Meta:
verbose_name = 'Footer'

@register_setting(icon='cogs')
class CloudfrontDistribution(BaseSetting):
class CloudfrontDistribution(BaseSiteSetting):
distribution_id = models.CharField(max_length=255, null=True, blank=True)

class Meta:
verbose_name = 'CloudFront Distribution'


@register_setting(icon='date')
class GiveToday(BaseSetting):
class GiveToday(BaseSiteSetting):
give_link_text = models.CharField(max_length=255)
give_link = models.URLField("Give link", blank=True, help_text="URL to Rice Give page or something similar")
start = models.DateTimeField(null=True,
Expand Down
2 changes: 1 addition & 1 deletion global_settings/signals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db.models.signals import post_save
from django.dispatch import receiver

from wagtail.core.signals import page_published
from wagtail.signals import page_published

from .functions import invalidate_cloudfront_caches
from .models import StickyNote, Footer, GiveToday
Expand Down
2 changes: 1 addition & 1 deletion global_settings/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler
from wagtail.core import hooks
from wagtail import hooks
from django.urls import reverse
from wagtail.admin.menu import MenuItem

Expand Down
Loading

0 comments on commit 80e330e

Please sign in to comment.