Jelajahi Sumber

Cleanup and bug fixes related to custom image models (#336)

Vince Salvino 4 tahun lalu
induk
melakukan
fb4304d411

+ 1 - 1
coderedcms/migrations/0001_initial.py

@@ -18,8 +18,8 @@ class Migration(migrations.Migration):
     initial = True
 
     dependencies = [
-        ('wagtailimages', '0020_add-verbose-name'),
         ('wagtailcore', '0040_page_draft_title'),
+        migrations.swappable_dependency(get_image_model_string()),
     ]
 
     operations = [

+ 9 - 4
coderedcms/models/page_models.py

@@ -49,12 +49,12 @@ from wagtail.core.models import Orderable, PageBase, Page, Site
 from wagtail.core.utils import resolve_model_string
 from wagtail.contrib.forms.edit_handlers import FormSubmissionsPanel
 from wagtail.contrib.forms.forms import WagtailAdminFormPageForm
+from wagtail.images import get_image_model_string
 from wagtail.images.edit_handlers import ImageChooserPanel
 from wagtail.contrib.forms.models import FormSubmission
 from wagtail.search import index
 from wagtail.utils.decorators import cached_classmethod
 from wagtailcache.cache import WagtailCacheMixin
-from wagtail.images import get_image_model_string
 
 from coderedcms import schema, utils
 from coderedcms.blocks import (
@@ -63,12 +63,17 @@ from coderedcms.blocks import (
     STREAMFORM_BLOCKS,
     ContentWallBlock,
     OpenHoursBlock,
-    StructuredDataActionBlock
+    StructuredDataActionBlock,
 )
 from coderedcms.fields import ColorField
 from coderedcms.forms import CoderedFormBuilder, CoderedSubmissionsListView
 from coderedcms.models.snippet_models import ClassifierTerm
-from coderedcms.models.wagtailsettings_models import GeneralSettings, LayoutSettings, SeoSettings, GoogleApiSettings  # noqa
+from coderedcms.models.wagtailsettings_models import (
+    GeneralSettings,
+    GoogleApiSettings,
+    LayoutSettings,
+    SeoSettings,
+)
 from coderedcms.wagtail_flexible_forms.blocks import FormFieldBlock, FormStepBlock
 from coderedcms.wagtail_flexible_forms.models import (
     Step,
@@ -76,7 +81,7 @@ from coderedcms.wagtail_flexible_forms.models import (
     StreamFormMixin,
     StreamFormJSONEncoder,
     SessionFormSubmission,
-    SubmissionRevision
+    SubmissionRevision,
 )
 from coderedcms.settings import cr_settings
 from coderedcms.widgets import ClassifierSelectWidget

+ 1 - 1
coderedcms/project_template/basic/website/models.py

@@ -18,7 +18,7 @@ class ArticlePage(CoderedArticlePage):
     """
     class Meta:
         verbose_name = 'Article'
-        ordering = ['-first_published_at', ]
+        ordering = ['-first_published_at']
 
     # Only allow this page to be created beneath an ArticleIndexPage.
     parent_page_types = ['website.ArticleIndexPage']

+ 2 - 1
coderedcms/project_template/sass/website/models.py

@@ -18,7 +18,7 @@ class ArticlePage(CoderedArticlePage):
     """
     class Meta:
         verbose_name = 'Article'
-        ordering = ['-first_published_at',]
+        ordering = ['-first_published_at']
 
     # Only allow this page to be created beneath an ArticleIndexPage.
     parent_page_types = ['website.ArticleIndexPage']
@@ -63,6 +63,7 @@ class FormPageField(CoderedFormField):
 
     page = ParentalKey('FormPage', related_name='form_fields')
 
+
 class FormConfirmEmail(CoderedEmail):
     """
     Sends a confirmation email after submitting a FormPage.

+ 20 - 5
docs/releases/v0.19.0.rst

@@ -5,11 +5,15 @@ CodeRed CMS 0.19.0 release notes
 Bug fixes
 ---------
 
+* Support custom image models by correctly using  ``WAGTAILIMAGES_IMAGE_MODEL``
+  versus hard-coding ``wagtailimages.Image``.
+
 
 New features
 ------------
 
 * Upgraded to Wagtail 2.9
+
 * Upgraded to Bootstrap 4.5 and jQuery 3.5.1
 
 
@@ -40,11 +44,22 @@ Upgrade considerations
 * If you have overridden ``coderedcms/pages/base.html``, you may need to update
   references to ``jquery-3.4.1`` to ``jquery-3.5.1``.
 
-* If using SASS, you may need to update your ``custom.scss`` or
-  ``_variables.scss`` files accordingly to support Bootstrap 4.5. Or you may
-  continue using Bootstrap 4.3 by `downloading a copy of the Bootstrap 4.3
-  sources <https://getbootstrap.com/docs/4.3/getting-started/download/>`_
-  and changing the references in your ``custom.scss`` to use these files.
+* If using SASS, you may need to update your ``custom.scss`` and/or
+  ``_variables.scss`` files accordingly to support Bootstrap 4.5. To see what
+  you might need to change in your ``_variables.scss``, see `the variables diff
+  of Bootstrap 4.3 to 4.5`_. Or to continue using Bootstrap 4.3, `download a
+  copy of the Bootstrap 4.3 sources`_ and change the references in your
+  ``custom.scss`` to use these files.
+
+* It is assumed that all CodeRed CMS sites prior to 0.19 are using the built-in
+  Wagtail Image model, as this was previously hard-coded in CodeRed CMS. If (and
+  only if) you plan to switch to a custom image model, a custom data migration
+  will be necessary. This migration would follow the same process as any other
+  Wagtail installation; there is nothing unique relating to CodeRed CMS.
 
 * You may need to run ``python manage.py makemigrations website`` and
   ``python manage.py migrate`` after upgrading.
+
+
+.. _the variables diff of Bootstrap 4.3 to 4.5: https://github.com/coderedcorp/coderedcms/commit/fa852ebc9d714d34b25c390321e5a6d563156097#diff-a68086c64c5d52852fda5605321c3eb9
+.. _download a copy of the Bootstrap 4.3 sources: https://getbootstrap.com/docs/4.3/getting-started/download/