Selaa lähdekoodia

Wagtail 2.13 (#418)

* Upgrade to Wagtail 2.13

* Replace unidecode with anyascii

* Replaced custom MultiSelectBlock with Wagtail's MultipleChoiceBlock, deleted uneccessary tests for this block as it is handled by Wagtail, added new migration, replaced initial migration

* Wagtail 2.13 uses 'nav-footer' and 'nav-footer-submenu' instead of
'footer' and 'footer-submenu' clsses.

* Increment version and add release notes

Co-authored-by: Kenneth Zhao <ken@epenguin.com>
Co-authored-by: Vince Salvino <salvino@coderedcorp.com>
Roxanna Coldiron 3 vuotta sitten
vanhempi
commit
0cbe4d5ca5

+ 1 - 1
coderedcms/__init__.py

@@ -14,7 +14,7 @@ Maintains version of coderedcms.
 
 See: https://www.python.org/dev/peps/pep-0440/
 """
-release = ["0", "20", "0", "", ""]
+release = ["0", "21", "0", "", ""]
 
 
 def _get_version() -> str:

+ 0 - 1
coderedcms/blocks/__init__.py

@@ -66,7 +66,6 @@ from .base_blocks import (  # noqa
     CoderedAdvSettings,
     CoderedAdvTrackingSettings,
     CollectionChooserBlock,
-    MultiSelectBlock
 )
 
 # Collections of blocks commonly used together.

+ 0 - 19
coderedcms/blocks/base_blocks.py

@@ -16,25 +16,6 @@ from wagtail.documents.blocks import DocumentChooserBlock
 from coderedcms.settings import cr_settings
 
 
-class MultiSelectBlock(blocks.FieldBlock):
-    """
-    Renders as MultipleChoiceField, used for adding checkboxes,
-    radios, or multiselect inputs in the streamfield.
-    """
-
-    def __init__(self, required=True, help_text=None, choices=None, widget=None, **kwargs):
-        self.field = forms.MultipleChoiceField(
-            required=required,
-            help_text=help_text,
-            choices=choices,
-            widget=widget,
-        )
-        super().__init__(**kwargs)
-
-    def get_searchable_content(self, value):
-        return [force_str(value)]
-
-
 class ClassifierTermChooserBlock(blocks.FieldBlock):
     """
     Enables choosing a ClassifierTerm in the streamfield.

+ 1 - 3
coderedcms/blocks/metadata_blocks.py

@@ -9,8 +9,6 @@ from wagtail.core import blocks
 
 from coderedcms import schema
 
-from .base_blocks import MultiSelectBlock
-
 
 class OpenHoursValue(blocks.StructValue):
     """
@@ -28,7 +26,7 @@ class OpenHoursBlock(blocks.StructBlock):
     """
     Holds day and time combination for business open hours.
     """
-    days = MultiSelectBlock(
+    days = blocks.MultipleChoiceBlock(
         required=True,
         verbose_name=_('Days'),
         help_text=_('For late night hours past 23:59, define each day in a separate block.'),

+ 0 - 21
coderedcms/blocks/tests/test_blocks.py

@@ -1,21 +0,0 @@
-from coderedcms.blocks import base_blocks
-from django.test import SimpleTestCase
-
-from wagtail.tests.utils import WagtailTestUtils
-
-
-class TestMultiSelectBlock(WagtailTestUtils, SimpleTestCase):
-    def test_render_single_choice(self):
-        block = base_blocks.MultiSelectBlock(
-            choices=[('tea', 'Tea'), ('coffee', 'Coffee'), ('water', 'Water')])
-        html = block.render_form(['tea'])
-        self.assertInHTML('<option value="tea" selected>Tea</option>', html)
-        self.assertTrue(html.count('selected'), 1)
-
-    def test_render_multi_choice(self):
-        block = base_blocks.MultiSelectBlock(
-            choices=[('tea', 'Tea'), ('coffee', 'Coffee'), ('water', 'Water')])
-        html = block.render_form(['coffee', 'tea'])
-        self.assertInHTML('<option value="tea" selected>Tea</option>', html)
-        self.assertInHTML('<option value="coffee" selected>Coffee</option>', html)
-        self.assertTrue(html.count('selected'), 2)

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

@@ -93,7 +93,7 @@ class Migration(migrations.Migration):
                 ('struct_org_address_country', models.CharField(blank=True, help_text='For example, USA. Two-letter ISO 3166-1 alpha-2 country code is also acceptible https://en.wikipedia.org/wiki/ISO_3166-1', max_length=255, verbose_name='Country')),
                 ('struct_org_geo_lat', models.DecimalField(blank=True, decimal_places=8, max_digits=10, null=True, verbose_name='Geographic latitude')),
                 ('struct_org_geo_lng', models.DecimalField(blank=True, decimal_places=8, max_digits=10, null=True, verbose_name='Geographic longitude')),
-                ('struct_org_hours', wagtail.core.fields.StreamField([('hours', wagtail.core.blocks.StructBlock([('days', coderedcms.blocks.base_blocks.MultiSelectBlock(choices=(('Monday', 'Monday'), ('Tuesday', 'Tuesday'), ('Wednesday', 'Wednesday'), ('Thursday', 'Thursday'), ('Friday', 'Friday'), ('Saturday', 'Saturday'), ('Sunday', 'Sunday')), help_text='For late night hours past 23:59, define each day in a separate block.', required=True, verbose_name='Days', widget=django.forms.widgets.CheckboxSelectMultiple)), ('start_time', wagtail.core.blocks.TimeBlock(verbose_name='Opening time')), ('end_time', wagtail.core.blocks.TimeBlock(verbose_name='Closing time'))]))], blank=True, verbose_name='Hours of operation')),
+                ('struct_org_hours', wagtail.core.fields.StreamField([('hours', wagtail.core.blocks.StructBlock([('days', wagtail.core.blocks.MultipleChoiceBlock(choices=(('Monday', 'Monday'), ('Tuesday', 'Tuesday'), ('Wednesday', 'Wednesday'), ('Thursday', 'Thursday'), ('Friday', 'Friday'), ('Saturday', 'Saturday'), ('Sunday', 'Sunday')), help_text='For late night hours past 23:59, define each day in a separate block.', required=True, verbose_name='Days', widget=django.forms.widgets.CheckboxSelectMultiple)), ('start_time', wagtail.core.blocks.TimeBlock(verbose_name='Opening time')), ('end_time', wagtail.core.blocks.TimeBlock(verbose_name='Closing time'))]))], blank=True, verbose_name='Hours of operation')),
                 ('struct_org_actions', wagtail.core.fields.StreamField([('actions', wagtail.core.blocks.StructBlock([('action_type', wagtail.core.blocks.ChoiceBlock(choices=[('OrderAction', 'OrderAction'), ('ReserveAction', 'ReserveAction')], verbose_name='Action Type')), ('target', wagtail.core.blocks.URLBlock(verbose_name='Target URL')), ('language', wagtail.core.blocks.CharBlock(default='en-US', help_text='If the action is offered in multiple languages, create separate actions for each language.', verbose_name='Language')), ('result_type', wagtail.core.blocks.ChoiceBlock(choices=[('Reservation', 'Reservation'), ('BusReservation', 'BusReservation'), ('EventReservation', 'EventReservation'), ('FlightReservation', 'FlightReservation'), ('FoodEstablishmentReservation', 'FoodEstablishmentReservation'), ('LodgingReservation', 'LodgingReservation'), ('RentalCarReservation', 'RentalCarReservation'), ('ReservationPackage', 'ReservationPackage'), ('TaxiReservation', 'TaxiReservation'), ('TrainReservation', 'TrainReservation')], help_text='Leave blank for OrderAction', required=False, verbose_name='Result Type')), ('result_name', wagtail.core.blocks.CharBlock(help_text='Example: "Reserve a table", "Book an appointment", etc.', required=False, verbose_name='Result Name')), ('extra_json', wagtail.core.blocks.RawHTMLBlock(classname='monospace', help_text='Additional JSON-LD inserted into the Action dictionary. Must be properties of https://schema.org/Action.', required=False, verbose_name='Additional action markup'))]))], blank=True, verbose_name='Actions')),
                 ('struct_org_extra_json', models.TextField(blank=True, help_text='Additional JSON-LD inserted into the Organization dictionary. Must be properties of https://schema.org/Organization or the selected organization type.', verbose_name='Additional Organization markup')),
                 ('cover_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=get_image_model_string(), verbose_name='Cover image')),

+ 20 - 0
coderedcms/migrations/0020_auto_20210527_1030.py

@@ -0,0 +1,20 @@
+# Generated by Django 3.1.7 on 2021-05-27 14:30
+
+from django.db import migrations
+import wagtail.core.blocks
+import wagtail.core.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('coderedcms', '0019_spelling_corrections'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='coderedpage',
+            name='struct_org_hours',
+            field=wagtail.core.fields.StreamField([('hours', wagtail.core.blocks.StructBlock([('days', wagtail.core.blocks.MultipleChoiceBlock(choices=[('Monday', 'Monday'), ('Tuesday', 'Tuesday'), ('Wednesday', 'Wednesday'), ('Thursday', 'Thursday'), ('Friday', 'Friday'), ('Saturday', 'Saturday'), ('Sunday', 'Sunday')], help_text='For late night hours past 23:59, define each day in a separate block.', verbose_name='Days')), ('start_time', wagtail.core.blocks.TimeBlock(verbose_name='Opening time')), ('end_time', wagtail.core.blocks.TimeBlock(verbose_name='Closing time'))]))], blank=True, verbose_name='Hours of operation'),
+        ),
+    ]

+ 4 - 3
coderedcms/static/coderedcms/css/codered-admin.css

@@ -246,16 +246,17 @@ input[type='checkbox']::before, input[type='radio']::before {
         width:100%;
     }
     .nav-main {
-        margin-bottom: 70px;
+        margin-bottom: 0px;
     }
     .nav-main .account em {
         margin-top:0.9em;
         font-size: 0.9em;
     }
-    .nav-main .footer-submenu {
+    .nav-main .nav-footer-submenu {
         overflow: hidden;
+        display: block;
     }
-    .footer .avatar {
+    .nav-footer .avatar {
         width: 40px;
         height: 40px;
     }

+ 2 - 2
coderedcms/templates/wagtailadmin/shared/main_nav.html

@@ -3,7 +3,7 @@
     <ul>
         {{ menu_html }}
 
-        <li class="footer" id="footer">
+        <li class="nav-footer" id="footer">
             <div class="account" id="account-settings" title="{% trans 'Edit your account' %}">
                 <span class="avatar square avatar-on-dark">
                     <img src="{% avatar_url request.user size=50 %}" alt="" />
@@ -11,7 +11,7 @@
                 <em class="icon icon-arrow-up-after">{{ request.user.first_name|default:request.user.get_username }}</em>
             </div>
 
-            <ul class="footer-submenu">
+            <ul class="nav-footer-submenu">
                 <li><a href="{% url 'wagtailadmin_account' %}" class="icon icon-user">{% trans "Account settings" %}</a></li>
                 <li><a href="{% url 'wagtailadmin_logout' %}" class="icon icon-logout">{% trans "Log out" %}</a></li>
             </ul>

+ 2 - 2
coderedcms/wagtail_flexible_forms/blocks.py

@@ -3,7 +3,7 @@ from django.db.models import BLANK_CHOICE_DASH
 from django.utils.dateparse import parse_datetime
 from django.utils.text import slugify
 from django.utils.translation import gettext_lazy as _
-from unidecode import unidecode
+from anyascii import anyascii
 from wagtail.core.blocks import (
     StructBlock, TextBlock, CharBlock, BooleanBlock, ListBlock, StreamBlock,
     DateBlock, TimeBlock, DateTimeBlock, ChoiceBlock, RichTextBlock,
@@ -18,7 +18,7 @@ class FormFieldBlock(StructBlock):
     widget = None
 
     def get_slug(self, struct_value):
-        return slugify(unidecode(struct_value['field_label']))
+        return slugify(anyascii(struct_value['field_label']))
 
     def get_field_class(self, struct_value):
         return self.field_class

+ 1 - 0
docs/releases/index.rst

@@ -17,6 +17,7 @@ CodeRed CMS follows the ``[major].[minor].[maintenance]`` versioning scheme.
 .. toctree::
     :maxdepth: 1
 
+    v0.21.0
     v0.20.0
     v0.19.1
     v0.19.0

+ 32 - 0
docs/releases/v0.21.0.rst

@@ -0,0 +1,32 @@
+v0.21.0 release notes
+=====================
+
+
+New features
+------------
+
+* Upgraded to Wagtail 2.13
+
+
+Upgrade considerations
+----------------------
+
+* ``coderedcms.blocks.MultiSelectBlock`` has been removed and is now replaced
+  with ``wagtail.core.blocks.MultipleChoiceBlock``.
+
+* You may need to find/replace
+  ``coderedcms.blocks.base_blocks.MultiSelectBlock`` with
+  ``wagtail.core.blocks.MultipleChoiceBlock`` in any old migrations so that they
+  may continue working.
+
+* Follow `Wagtail 2.12 upgrade considerations <https://docs.wagtail.io/en/stable/releases/2.12.html#upgrade-considerations>`_
+  and `Wagtail 2.13 upgrade considerations <https://docs.wagtail.io/en/stable/releases/2.13.html#upgrade-considerations>`_.
+
+* You may need to run ``python manage.py makemigrations website`` and
+  ``python manage.py migrate`` after upgrading.
+
+
+Thank you!
+----------
+
+Thanks to everyone who contributed to `0.21.0 on GitHub <https://github.com/coderedcorp/coderedcms/milestone/31?closed=1>`_.

+ 1 - 1
setup.py

@@ -49,7 +49,7 @@ setup(
         'Django>=2.2,<3.2',             # should be the same as wagtail
         'geocoder==1.38.*',
         'icalendar==4.0.*',
-        'wagtail==2.11.*',
+        'wagtail==2.13.*',
         'wagtailfontawesome>=1.2.*',
         'wagtail-cache==1.*',
         'wagtail-import-export>=0.2,<0.3'