From 51f427888574380045685c85806fbf45f73cdd2b Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Mon, 6 Nov 2023 22:24:36 +0530 Subject: [PATCH] Upgrade wagtail to 5x (#3627) Notes: Wagtail 5x has migrations: ``` You have 11 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): wagtailcore, wagtailsearchpromotions, wagtailusers. ``` --- hypha/apply/categories/blocks.py | 1 + hypha/apply/funds/admin.py | 2 +- hypha/apply/funds/blocks.py | 1 + hypha/apply/projects/admin.py | 2 +- hypha/apply/stream_forms/blocks.py | 8 +- hypha/apply/utils/blocks.py | 2 +- hypha/public/utils/wagtail_hooks.py | 8 -- .../src/sass/apply/wagtail_editor.scss | 98 ------------------- requirements.txt | 6 +- 9 files changed, 14 insertions(+), 114 deletions(-) delete mode 100644 hypha/static_src/src/sass/apply/wagtail_editor.scss diff --git a/hypha/apply/categories/blocks.py b/hypha/apply/categories/blocks.py index 0ff38b1696..0b053b04f3 100644 --- a/hypha/apply/categories/blocks.py +++ b/hypha/apply/categories/blocks.py @@ -21,6 +21,7 @@ def get_categories_as_choices(): class CategoryQuestionBlock(OptionalFormFieldBlock): class Meta: template = "stream_forms/render_list_field.html" + icon = "folder-open-1" category = ModelChooserBlock(required=True, choices=get_categories_as_choices) multi = BooleanBlock(label=_("Multi select"), required=False) diff --git a/hypha/apply/funds/admin.py b/hypha/apply/funds/admin.py index 9c6241c987..50fe3bbf22 100644 --- a/hypha/apply/funds/admin.py +++ b/hypha/apply/funds/admin.py @@ -179,7 +179,7 @@ class ReviewerSettingAdmin(SettingModelAdmin): class ApplyAdminGroup(ModelAdminGroup): menu_label = "Apply" - menu_icon = "folder-open-inverse" + menu_icon = "folder-inverse" items = ( RoundAdmin, SealedRoundAdmin, diff --git a/hypha/apply/funds/blocks.py b/hypha/apply/funds/blocks.py index e40b2e9063..8b89f24878 100644 --- a/hypha/apply/funds/blocks.py +++ b/hypha/apply/funds/blocks.py @@ -48,6 +48,7 @@ class ValueBlock(ApplicationSingleIncludeFieldBlock): class Meta: label = _("Requested amount") + icon = "decimal" def prepare_data(self, value, data, serialize): return format_number_as_currency(str(data)) diff --git a/hypha/apply/projects/admin.py b/hypha/apply/projects/admin.py index a435351ccf..6a3b58fed4 100644 --- a/hypha/apply/projects/admin.py +++ b/hypha/apply/projects/admin.py @@ -81,7 +81,7 @@ class VendorFormSettingsAdmin(SettingModelAdmin): class ProjectAdminGroup(ModelAdminGroup): menu_label = "Projects" - menu_icon = "duplicate" + menu_icon = "folder-open-1" items = ( ContractDocumentCategoryAdmin, DocumentCategoryAdmin, diff --git a/hypha/apply/stream_forms/blocks.py b/hypha/apply/stream_forms/blocks.py index 6059e66eed..e67c7e57d8 100644 --- a/hypha/apply/stream_forms/blocks.py +++ b/hypha/apply/stream_forms/blocks.py @@ -127,6 +127,7 @@ class CharFieldBlock(OptionalFormFieldBlock): class Meta: label = _("Text field (single line)") + icon = "minus" template = "stream_forms/render_unsafe_field.html" def get_field_class(self, struct_value): @@ -149,6 +150,7 @@ class MultiInputCharFieldBlock(CharFieldBlock): class Meta: label = _("Text field (single line) (multiple inputs)") + icon = "bars" class TextFieldBlock(OptionalFormFieldBlock): @@ -159,6 +161,7 @@ class TextFieldBlock(OptionalFormFieldBlock): class Meta: label = _("Text field (multi line)") + icon = "edit" template = "stream_forms/render_unsafe_field.html" def get_searchable_content(self, value, data): @@ -172,6 +175,7 @@ class NumberFieldBlock(OptionalFormFieldBlock): class Meta: label = _("Number field") + icon = "decimal" def get_searchable_content(self, value, data): return None @@ -256,7 +260,7 @@ class DropdownFieldBlock(RadioButtonsFieldBlock): class Meta: label = _("Dropdown field") - icon = "arrow-down-big" + icon = "arrow-down" def get_field_kwargs(self, struct_value): kwargs = super().get_field_kwargs(struct_value) @@ -272,7 +276,7 @@ class CheckboxesFieldBlock(OptionalFormFieldBlock): class Meta: label = _("Multiple checkboxes field") - icon = "list-ul" + icon = "tasks" template = "stream_forms/render_list_field.html" def get_field_kwargs(self, struct_value): diff --git a/hypha/apply/utils/blocks.py b/hypha/apply/utils/blocks.py index 0f1cd2af0e..7f74b0c508 100644 --- a/hypha/apply/utils/blocks.py +++ b/hypha/apply/utils/blocks.py @@ -95,7 +95,7 @@ def clean(self, value): try: value = super().clean(value) except ValidationError as e: - error_dict = e.params + error_dict = e.params or {} else: error_dict = {} diff --git a/hypha/public/utils/wagtail_hooks.py b/hypha/public/utils/wagtail_hooks.py index 7c1befc1d7..d6d603b409 100644 --- a/hypha/public/utils/wagtail_hooks.py +++ b/hypha/public/utils/wagtail_hooks.py @@ -1,4 +1,3 @@ -from django.templatetags.static import static from wagtail import hooks from wagtail.contrib.modeladmin.options import ( ModelAdmin, @@ -30,13 +29,6 @@ class TaxonomiesModelAdminGroup(ModelAdminGroup): modeladmin_register(TaxonomiesModelAdminGroup) -@hooks.register("insert_editor_css") -def editor_css(): - link = '\n' - path = static("css/apply/wagtail_editor.css") - return link.format(path) - - @hooks.register("after_create_page") @hooks.register("after_edit_page") def clear_wagtailcache(request, page): diff --git a/hypha/static_src/src/sass/apply/wagtail_editor.scss b/hypha/static_src/src/sass/apply/wagtail_editor.scss deleted file mode 100644 index 06c93c0986..0000000000 --- a/hypha/static_src/src/sass/apply/wagtail_editor.scss +++ /dev/null @@ -1,98 +0,0 @@ -// stylelint-disable block-no-empty - -// Abstracts -@import "abstracts/functions"; -@import "abstracts/mixins"; -@import "abstracts/variables"; - -.wmd-panel { -} - -.wmd-input { -} - -.wmd-preview { - background-color: $color--sky-blue; - padding: 0 10px; - width: 100%; - overflow: hidden; /* prevent collapsing margins */ - - p { - margin: 1em 0; - } - - ul { - padding-left: 20px; - - li { - list-style: outside disc; - } - } - - ol { - padding-left: 0; - - li { - list-style: inside decimal; - } - } -} - -.wmd-button-row { - position: relative; - background-color: $color--white; - height: 25px; - padding: 10px 5px 5px; -} - -.wmd-spacer { - position: absolute; - display: inline-block; - background-color: $color--mid-grey; - width: 1px; - height: 20px; - margin-left: 14px; - list-style: none; -} - -.wmd-button { - position: absolute; - display: inline-block; - width: 20px; - height: 20px; - padding-left: 2px; - padding-right: 3px; - list-style: none; - cursor: pointer; - - & > span { - display: inline-block; - background-image: url("./../../images/editor-buttons.png"); - background-repeat: no-repeat; - background-position: 0 0; - width: 20px; - height: 20px; - } -} - -.wmd-spacer1 { - left: 50px; -} - -.wmd-spacer2 { - left: 175px; -} - -.wmd-spacer3 { - left: 300px; -} - -.wmd-prompt-background { - background-color: $color--black; -} - -.wmd-prompt-dialog { - background-color: $color--light-grey; - padding: 0.5em; - border: 4px solid $color--primary; -} diff --git a/requirements.txt b/requirements.txt index 6812a1fc48..c2357250a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -49,16 +49,16 @@ mailchimp3==3.0.17 mistune==2.0.4 more-itertools==9.0.0 phonenumberslite==8.13.23 -Pillow==9.4.0 +Pillow>=10.0.1 psycopg2-binary qrcode==7.4.2 reportlab==3.6.13 social_auth_app_django==5.0.0 tablib==3.5.0 tomd==0.1.3 -wagtail-cache==2.2.0 +wagtail-cache==2.3.0 wagtail-purge==0.3.0 -wagtail==4.2.2 +wagtail==5.1.3 whitenoise==5.3.0 xhtml2pdf==0.2.11 xmltodict==0.13.0