Browse Source

Wagtail 4.* (#556)

Supports Wagtail 4.0, 4.1, and 4.2. Thankfully they have held fast to
semantic versioning and there are no conflicts in our project between
those versions.

Other changes:
* Pin wagtail version in boilerplate requirements.txt
* Streamline boilerplate settings.

This will close #534 #535

Thanks to @htran-ubed for getting this started!
Vince Salvino 2 years ago
parent
commit
8d4f23c5c1

+ 2 - 12
coderedcms/bin/coderedcms.py

@@ -6,18 +6,6 @@ from django.core.management.templates import TemplateCommand
 from django.core.management.utils import get_random_secret_key
 
 
-CURRENT_PYTHON = sys.version_info[:2]
-REQUIRED_PYTHON = (3, 4)
-
-if CURRENT_PYTHON < REQUIRED_PYTHON:
-    sys.stderr.write(
-        "This version of Wagtail requires Python {}.{} or above - you are running {}.{}\n".format(
-            *(REQUIRED_PYTHON + CURRENT_PYTHON)
-        )
-    )
-    sys.exit(1)
-
-
 class CreateProject(TemplateCommand):
     """
     Based on django.core.management.startproject
@@ -59,6 +47,7 @@ class CreateProject(TemplateCommand):
 
         # Handle custom template logic
         import coderedcms
+        import wagtail
 
         crx_path = os.path.dirname(coderedcms.__file__)
         if not options["template"]:
@@ -99,6 +88,7 @@ class CreateProject(TemplateCommand):
 
         # Add additional custom options to the context.
         options["coderedcms_release"] = coderedcms.release
+        options["wagtail_release"] = wagtail.VERSION
 
         # Print a friendly message
         print(

+ 8 - 0
coderedcms/models/page_models.py

@@ -1573,6 +1573,14 @@ class CoderedFormMixin(models.Model):
             return self.process_form_post(form, request)
         return self.process_form_get(form, request)
 
+    def get_preview_context(self, request, *args, **kwargs):
+        """
+        In preview mode, simlpy show a blank form but do not handle submissions.
+        """
+        ctx = super().get_preview_context(request, *args, **kwargs)
+        ctx["form"] = self.get_form(request, page=self, user=request.user)
+        return ctx
+
 
 class CoderedFormPage(CoderedFormMixin, CoderedWebPage):
     """

+ 3 - 3
coderedcms/models/wagtailsettings_models.py

@@ -15,7 +15,7 @@ from wagtail.admin.panels import (
     MultiFieldPanel,
 )
 from wagtail.models import Orderable
-from wagtail.contrib.settings.models import BaseSetting, register_setting
+from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
 from wagtail.images import get_image_model_string
 from coderedcms.fields import MonospaceField
 from coderedcms.settings import crx_settings
@@ -23,7 +23,7 @@ from coderedcms.models.snippet_models import Navbar, Footer
 
 
 @register_setting(icon="cr-desktop")
-class LayoutSettings(ClusterableModel, BaseSetting):
+class LayoutSettings(ClusterableModel, BaseSiteSetting):
     """
     Branding, navbar, and theme settings.
     """
@@ -257,7 +257,7 @@ class FooterOrderable(Orderable, models.Model):
 
 
 @register_setting(icon="cr-google")
-class AnalyticsSettings(BaseSetting):
+class AnalyticsSettings(BaseSiteSetting):
     """
     Tracking and Google Analytics.
     """

+ 1 - 1
coderedcms/project_template/basic/project_name/settings/dev.py

@@ -13,6 +13,6 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
 WAGTAIL_CACHE = False
 
 try:
-    from .local_settings import *  # noqa
+    from .local import *  # noqa
 except ImportError:
     pass

+ 1 - 42
coderedcms/project_template/basic/project_name/settings/prod.py

@@ -12,7 +12,7 @@ ALLOWED_HOSTS = ["{{ domain }}"]
 # To send email from the server, we recommend django_sendmail_backend
 # Or specify your own email backend such as an SMTP server.
 # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#email-backend
-EMAIL_BACKEND = "django_sendmail_backend.backends.EmailBackend"
+# EMAIL_BACKEND = "django_sendmail_backend.backends.EmailBackend"
 
 # Default email address used to send messages from the website.
 DEFAULT_FROM_EMAIL = "{{ sitename }} <info@{{ domain_nowww }}>"
@@ -29,42 +29,6 @@ MANAGERS = ADMINS
 # Email address used to send error messages to ADMINS.
 SERVER_EMAIL = DEFAULT_FROM_EMAIL
 
-# DATABASES = {
-#     'default': {
-#         'ENGINE': 'django.db.backends.mysql',
-#         'HOST': 'localhost',
-#         'NAME': '{{ project_name }}',
-#         'USER': '{{ project_name }}',
-#         'PASSWORD': '',
-#     }
-# }
-
-# Use template caching to speed up wagtail admin and front-end.
-# Requires reloading web server to pick up template changes.
-TEMPLATES = [
-    {
-        "BACKEND": "django.template.backends.django.DjangoTemplates",
-        "OPTIONS": {
-            "context_processors": [
-                "django.template.context_processors.debug",
-                "django.template.context_processors.request",
-                "django.contrib.auth.context_processors.auth",
-                "django.contrib.messages.context_processors.messages",
-                "wagtail.contrib.settings.context_processors.settings",
-            ],
-            "loaders": [
-                (
-                    "django.template.loaders.cached.Loader",
-                    [
-                        "django.template.loaders.filesystem.Loader",
-                        "django.template.loaders.app_directories.Loader",
-                    ],
-                ),
-            ],
-        },
-    },
-]
-
 CACHES = {
     "default": {
         "BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
@@ -73,8 +37,3 @@ CACHES = {
         "TIMEOUT": 14400,  # in seconds
     }
 }
-
-try:
-    from .local_settings import *  # noqa
-except ImportError:
-    pass

+ 1 - 9
coderedcms/project_template/basic/requirements.txt

@@ -1,10 +1,2 @@
 coderedcms=={{coderedcms_release.0}}.{{coderedcms_release.1}}.*
-
-# django_sendmail_backend enables sending email from your web host server.
-# Remove this if using a different email backend.
-django_sendmail_backend
-
-# To use with MariaDB or MySQL, uncomment the line below:
-#mysqlclient
-# To use with PostgreSQL, uncomment the line below:
-#psycopg2
+wagtail=={{wagtail_release.0}}.{{wagtail_release.1}}.*

+ 1 - 37
coderedcms/project_template/sass/project_name/settings/prod.py

@@ -12,7 +12,7 @@ ALLOWED_HOSTS = ["{{ domain }}"]
 # To send email from the server, we recommend django_sendmail_backend
 # Or specify your own email backend such as an SMTP server.
 # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#email-backend
-EMAIL_BACKEND = "django_sendmail_backend.backends.EmailBackend"
+# EMAIL_BACKEND = "django_sendmail_backend.backends.EmailBackend"
 
 # Default email address used to send messages from the website.
 DEFAULT_FROM_EMAIL = "{{ sitename }} <info@{{ domain_nowww }}>"
@@ -29,42 +29,6 @@ MANAGERS = ADMINS
 # Email address used to send error messages to ADMINS.
 SERVER_EMAIL = DEFAULT_FROM_EMAIL
 
-# DATABASES = {
-#    'default': {
-#        'ENGINE': 'django.db.backends.mysql',
-#        'HOST': 'localhost',
-#        'NAME': '{{ project_name }}',
-#        'USER': '{{ project_name }}',
-#        'PASSWORD': '',
-#    }
-# }
-
-# Use template caching to speed up wagtail admin and front-end.
-# Requires reloading web server to pick up template changes.
-TEMPLATES = [
-    {
-        "BACKEND": "django.template.backends.django.DjangoTemplates",
-        "OPTIONS": {
-            "context_processors": [
-                "django.template.context_processors.debug",
-                "django.template.context_processors.request",
-                "django.contrib.auth.context_processors.auth",
-                "django.contrib.messages.context_processors.messages",
-                "wagtail.contrib.settings.context_processors.settings",
-            ],
-            "loaders": [
-                (
-                    "django.template.loaders.cached.Loader",
-                    [
-                        "django.template.loaders.filesystem.Loader",
-                        "django.template.loaders.app_directories.Loader",
-                    ],
-                ),
-            ],
-        },
-    },
-]
-
 CACHES = {
     "default": {
         "BACKEND": "django.core.cache.backends.filebased.FileBasedCache",

+ 3 - 9
coderedcms/project_template/sass/requirements.txt

@@ -1,10 +1,4 @@
+# Consult release notes for supported versions of Django, Wagtail, and Python.
+# https://docs.coderedcorp.com/wagtail-crx/releases/
 coderedcms=={{coderedcms_release.0}}.{{coderedcms_release.1}}.*
-
-# django_sendmail_backend enables sending email from your web host server.
-# Remove this if using a different email backend.
-django_sendmail_backend
-
-# To use with MariaDB or MySQL, uncomment the line below:
-#mysqlclient
-# To use with PostgreSQL, uncomment the line below:
-#psycopg2
+wagtail=={{wagtail_release.0}}.{{wagtail_release.1}}.*

+ 1 - 1
coderedcms/static/coderedcms/css/crx-editor.css

@@ -7,7 +7,7 @@ License: https://github.com/coderedcorp/coderedcms/blob/dev/LICENSE
 
 .crx-collapsible {
     padding:0;
-    margin-top: -40px;
+    margin-top: -36px;
 }
 .crx-collapsible .crx-collapsible-target {
     padding: 10px 0 0;

+ 1 - 1
coderedcms/templates/coderedcms/widgets/checkbox_classifiers.html

@@ -34,7 +34,7 @@
     {% trans "Use Classifiers to create custom categories and filters."%}
   </p>
   <div>
-    <a class="button bicolor icon icon-plus" href="{% url 'wagtailsnippets:add' 'coderedcms' 'classifier' %}">
+    <a class="button bicolor icon icon-plus" href="{% url 'wagtailsnippets_coderedcms_classifier:add' %}">
       {% trans "Add Classifier" %}
     </a>
   </div>

+ 1 - 4
coderedcms/wagtail_flexible_forms/models.py

@@ -33,7 +33,6 @@ from django.template.response import TemplateResponse
 from django.utils.safestring import SafeData, mark_safe
 from django.utils.timezone import now
 from django.utils.translation import gettext_lazy as _
-from wagtail.models import Page
 from wagtail.contrib.forms.models import (
     AbstractForm,
     AbstractEmailForm,
@@ -686,8 +685,6 @@ class SubmissionRevision(Model):
 
 
 class StreamFormMixin:
-    preview_modes = Page.DEFAULT_PREVIEW_MODES
-
     @property
     def current_step_session_key(self):
         return "%s:step" % self.pk
@@ -789,7 +786,7 @@ class StreamFormMixin:
             if is_complete:
                 return self.serve_success(request, *args, **kwargs)
             return HttpResponseRedirect(self.url)
-        return Page.serve(self, request, *args, **kwargs)
+        return super().serve(self, request, *args, **kwargs)
 
     def get_data_fields(self, by_step=False, add_metadata=True):
         if by_step:

+ 9 - 7
setup.py

@@ -33,27 +33,29 @@ setup(
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
         "Programming Language :: Python :: 3 :: Only",
         "Framework :: Django",
         "Framework :: Django :: 3.2",
         "Framework :: Django :: 4.0",
+        "Framework :: Django :: 4.1",
         "Framework :: Wagtail",
-        "Framework :: Wagtail :: 2",
+        "Framework :: Wagtail :: 4",
         "Topic :: Internet :: WWW/HTTP",
         "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
         "Topic :: Internet :: WWW/HTTP :: Site Management",
     ],
     python_requires=">=3.7",
     install_requires=[
-        "beautifulsoup4>=4.8,<4.10",  # should be the same as wagtail
+        "beautifulsoup4>=4.8,<4.12",  # should be the same as wagtail
         "django-eventtools==1.0.*",
-        "django-bootstrap5==21.3",
-        "Django>=3.2,<4.1",  # should be the same as wagtail
+        "django-bootstrap5==22.2",
+        "Django>=3.2,<4.2",  # should be the same as wagtail
         "geocoder==1.38.*",
         "icalendar==4.1.*",
-        "wagtail==3.*",
-        "wagtail-cache==2.*",
-        "wagtail-seo>=2.2,<3",
+        "wagtail>=4.0,<4.3",
+        "wagtail-cache>=2.2,<3",
+        "wagtail-seo>=2.3,<3",
     ],
     entry_points={
         "console_scripts": ["coderedcms=coderedcms.bin.coderedcms:main"]