From 3a9ad53e7a667c9608efe803c27404538630a3c7 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Tue, 7 Jun 2022 18:16:53 +0200 Subject: [PATCH] Upgrade to Wagtail 3.0 --- .tool-versions | 2 +- server/config/settings/base.py | 15 ++---- server/config/urls.py | 4 +- server/requirements/requirements-dev.in | 1 - server/requirements/requirements-dev.txt | 51 +++---------------- server/requirements/requirements.in | 4 +- server/requirements/requirements.txt | 49 +++--------------- .../management/commands/migrate_locales.py | 2 +- .../learnpath/migrations/0001_initial.py | 6 +-- server/vbv_lernwelt/learnpath/models.py | 8 ++- .../learnpath/models_competences.py | 4 +- .../learnpath/models_learning_unit_content.py | 2 +- .../tests/create_default_learning_path.py | 2 +- .../test_create_default_learning_path.py | 2 +- 14 files changed, 33 insertions(+), 119 deletions(-) diff --git a/.tool-versions b/.tool-versions index 2eb57b52..a6a8eac6 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ nodejs 16.10.0 -python 3.10.0 +python 3.10.5 diff --git a/server/config/settings/base.py b/server/config/settings/base.py index 91369c6a..c26fa569 100644 --- a/server/config/settings/base.py +++ b/server/config/settings/base.py @@ -2,10 +2,9 @@ Base settings to build other settings files upon. """ import logging -from pathlib import Path - import structlog from environs import Env +from pathlib import Path from vbv_lernwelt.core.utils import structlog_add_app_info @@ -82,6 +81,7 @@ THIRD_PARTY_APPS = [ 'wagtail.contrib.forms', 'wagtail.contrib.redirects', + 'wagtail.contrib.styleguide', 'wagtail.embeds', 'wagtail.sites', 'wagtail.users', @@ -90,7 +90,7 @@ THIRD_PARTY_APPS = [ 'wagtail.images', 'wagtail.search', 'wagtail.admin', - 'wagtail.core', + 'wagtail', 'wagtail.locales', 'wagtail.api.v2', @@ -222,15 +222,6 @@ WAGTAILSEARCH_BACKENDS = { } } -# Wagtails Grapple Config: -GRAPHENE = {"SCHEMA": "grapple.schema.schema"} -GRAPPLE = { - "APPS": ["learnpath"], -"EXPOSE_GRAPHIQL" : True - -} - - # TEMPLATES # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#templates diff --git a/server/config/urls.py b/server/config/urls.py index 25023fe1..6d8d9bf1 100644 --- a/server/config/urls.py +++ b/server/config/urls.py @@ -7,11 +7,10 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import include, path, re_path from django.views import defaults as default_views from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView -from grapple import urls as grapple_urls from ratelimit.exceptions import Ratelimited from rest_framework.authtoken.views import obtain_auth_token +from wagtail import urls as wagtail_urls from wagtail.admin import urls as wagtailadmin_urls -from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls from vbv_lernwelt.core.middleware.auth import django_view_authentication_exempt @@ -63,7 +62,6 @@ urlpatterns += [ path("auth-token/", obtain_auth_token), path("api/schema/", SpectacularAPIView.as_view(), name="api-schema"), path("api/docs/", SpectacularSwaggerView.as_view(url_name="api-schema"), name="api-docs",), - path("", include(grapple_urls)), ] if settings.APP_ENVIRONMENT != 'production': diff --git a/server/requirements/requirements-dev.in b/server/requirements/requirements-dev.in index fccb5037..ee33d498 100644 --- a/server/requirements/requirements-dev.in +++ b/server/requirements/requirements-dev.in @@ -4,7 +4,6 @@ Werkzeug[watchdog] # https://github.com/pallets/werkzeug ipdb # https://github.com/gotcha/ipdb watchgod # https://github.com/samuelcolvin/watchgod pip-tools -pip<22 # Testing # ------------------------------------------------------------------------------ diff --git a/server/requirements/requirements-dev.txt b/server/requirements/requirements-dev.txt index 39ea0e68..b7892288 100644 --- a/server/requirements/requirements-dev.txt +++ b/server/requirements/requirements-dev.txt @@ -4,8 +4,6 @@ # # pip-compile --output-file=requirements-dev.txt requirements-dev.in # -aniso8601==7.0.0 - # via graphene anyascii==0.3.1 # via wagtail anyio==3.5.0 @@ -80,7 +78,7 @@ distlib==0.3.4 # via virtualenv dj-database-url==0.5.0 # via -r requirements.in -django==3.2.12 +django==3.2.13 # via # -r requirements.in # django-cors-headers @@ -89,6 +87,8 @@ django==3.2.12 # django-filter # django-htmx # django-model-utils + # django-modelcluster + # django-permissionedforms # django-redis # django-stubs # django-stubs-ext @@ -96,9 +96,7 @@ django==3.2.12 # django-treebeard # djangorestframework # drf-spectacular - # graphene-django # wagtail - # wagtail-grapple django-click==2.3.0 # via -r requirements.in django-cors-headers==3.11.0 @@ -117,7 +115,9 @@ django-ipware==4.0.2 # via -r requirements.in django-model-utils==4.2.0 # via -r requirements.in -django-modelcluster==5.3 +django-modelcluster==6.0 + # via wagtail +django-permissionedforms==0.1 # via wagtail django-ratelimit==3.0.1 # via -r requirements.in @@ -170,18 +170,6 @@ gitdb2==4.0.2 # via gitpython gitpython==3.0.6 # via trufflehog -graphene==2.1.9 - # via graphene-django -graphene-django==2.13.0 - # via wagtail-grapple -graphql-core==2.3.2 - # via - # graphene - # graphene-django - # graphql-relay - # wagtail-grapple -graphql-relay==2.0.1 - # via graphene gunicorn==20.1.0 # via -r requirements.in h11==0.13.0 @@ -265,7 +253,7 @@ pillow==9.0.1 # via # -r requirements.in # wagtail -pip-tools==6.5.1 +pip-tools==6.6.2 # via -r requirements-dev.in platformdirs==2.5.1 # via @@ -278,11 +266,6 @@ portalocker==2.4.0 # via concurrent-log-handler pre-commit==2.17.0 # via -r requirements-dev.in -promise==2.3 - # via - # graphene-django - # graphql-core - # graphql-relay prompt-toolkit==3.0.28 # via ipython psycopg2-binary==2.9.3 @@ -353,25 +336,15 @@ requests==2.27.1 # coreapi # djangorestframework-stubs # wagtail -rx==1.6.1 - # via graphql-core sentry-sdk==1.5.8 # via -r requirements.in -singledispatch==3.7.0 - # via graphene-django six==1.16.0 # via # asttokens # django-coverage-plugin - # graphene - # graphene-django - # graphql-core - # graphql-relay # html5lib # l18n - # promise # python-dateutil - # singledispatch # virtualenv smmap==5.0.0 # via gitdb @@ -427,8 +400,6 @@ typing-extensions==4.1.1 # django-stubs-ext # djangorestframework-stubs # mypy -unidecode==1.3.4 - # via graphene-django uritemplate==4.1.1 # via # coreapi @@ -443,18 +414,12 @@ uvloop==0.16.0 # via uvicorn virtualenv==20.14.0 # via pre-commit -wagtail==2.16.2 +wagtail==3.0.0 # via # -r requirements.in # wagtail-factories - # wagtail-grapple - # wagtail-headless-preview wagtail-factories==2.0.1 # via -r requirements.in -wagtail-grapple==0.14.1 - # via -r requirements.in -wagtail-headless-preview==0.2.1 - # via wagtail-grapple watchdog==2.1.7 # via werkzeug watchgod==0.8.1 diff --git a/server/requirements/requirements.in b/server/requirements/requirements.in index 9544fc7e..ca86bc90 100644 --- a/server/requirements/requirements.in +++ b/server/requirements/requirements.in @@ -33,7 +33,5 @@ structlog python-json-logger concurrent-log-handler -wagtail<3 +wagtail>=3,<4 wagtail-factories -wagtail-grapple==0.14.1 - diff --git a/server/requirements/requirements.txt b/server/requirements/requirements.txt index 527de4ec..e0c64c8b 100644 --- a/server/requirements/requirements.txt +++ b/server/requirements/requirements.txt @@ -4,8 +4,6 @@ # # pip-compile --output-file=requirements.txt requirements.in # -aniso8601==7.0.0 - # via graphene anyascii==0.3.1 # via wagtail anyio==3.5.0 @@ -48,21 +46,21 @@ deprecated==1.2.13 # via redis dj-database-url==0.5.0 # via -r requirements.in -django==3.2.12 +django==3.2.13 # via # -r requirements.in # django-cors-headers # django-filter # django-htmx # django-model-utils + # django-modelcluster + # django-permissionedforms # django-redis # django-taggit # django-treebeard # djangorestframework # drf-spectacular - # graphene-django # wagtail - # wagtail-grapple django-click==2.3.0 # via -r requirements.in django-cors-headers==3.11.0 @@ -75,7 +73,9 @@ django-ipware==4.0.2 # via -r requirements.in django-model-utils==4.2.0 # via -r requirements.in -django-modelcluster==5.3 +django-modelcluster==6.0 + # via wagtail +django-permissionedforms==0.1 # via wagtail django-ratelimit==3.0.1 # via -r requirements.in @@ -102,18 +102,6 @@ factory-boy==3.2.1 # via wagtail-factories faker==13.11.1 # via factory-boy -graphene==2.1.9 - # via graphene-django -graphene-django==2.13.0 - # via wagtail-grapple -graphql-core==2.3.2 - # via - # graphene - # graphene-django - # graphql-relay - # wagtail-grapple -graphql-relay==2.0.1 - # via graphene gunicorn==20.1.0 # via -r requirements.in h11==0.13.0 @@ -148,11 +136,6 @@ pillow==9.0.1 # wagtail portalocker==2.4.0 # via concurrent-log-handler -promise==2.3 - # via - # graphene-django - # graphql-core - # graphql-relay psycopg2-binary==2.9.3 # via -r requirements.in pycparser==2.21 @@ -188,23 +171,13 @@ redis==4.2.1 # django-redis requests==2.27.1 # via wagtail -rx==1.6.1 - # via graphql-core sentry-sdk==1.5.8 # via -r requirements.in -singledispatch==3.7.0 - # via graphene-django six==1.16.0 # via - # graphene - # graphene-django - # graphql-core - # graphql-relay # html5lib # l18n - # promise # python-dateutil - # singledispatch sniffio==1.2.0 # via anyio soupsieve==2.3.2.post1 @@ -219,8 +192,6 @@ telepath==0.2 # via wagtail text-unidecode==1.3 # via python-slugify -unidecode==1.3.4 - # via graphene-django uritemplate==4.1.1 # via drf-spectacular urllib3==1.26.9 @@ -231,18 +202,12 @@ uvicorn[standard]==0.17.6 # via -r requirements.in uvloop==0.16.0 # via uvicorn -wagtail==2.16.2 +wagtail==3.0.0 # via # -r requirements.in # wagtail-factories - # wagtail-grapple - # wagtail-headless-preview wagtail-factories==2.0.1 # via -r requirements.in -wagtail-grapple==0.14.1 - # via -r requirements.in -wagtail-headless-preview==0.2.1 - # via wagtail-grapple watchgod==0.8.1 # via uvicorn webencodings==0.5.1 diff --git a/server/vbv_lernwelt/core/management/commands/migrate_locales.py b/server/vbv_lernwelt/core/management/commands/migrate_locales.py index 4bc583e4..da4f4891 100644 --- a/server/vbv_lernwelt/core/management/commands/migrate_locales.py +++ b/server/vbv_lernwelt/core/management/commands/migrate_locales.py @@ -1,6 +1,6 @@ import djclick as click from django.conf import settings -from wagtail.core.models import Locale +from wagtail.models import Locale @click.command() diff --git a/server/vbv_lernwelt/learnpath/migrations/0001_initial.py b/server/vbv_lernwelt/learnpath/migrations/0001_initial.py index e16881cf..ca629695 100644 --- a/server/vbv_lernwelt/learnpath/migrations/0001_initial.py +++ b/server/vbv_lernwelt/learnpath/migrations/0001_initial.py @@ -3,8 +3,8 @@ from django.db import migrations, models import django.db.models.deletion import modelcluster.fields -import wagtail.core.blocks -import wagtail.core.fields +import wagtail.blocks +import wagtail.fields class Migration(migrations.Migration): @@ -65,7 +65,7 @@ class Migration(migrations.Migration): ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), ('minutes', models.PositiveIntegerField(default=15)), ('package', models.CharField(blank=True, default='', max_length=255)), - ('contents', wagtail.core.fields.StreamField([('video', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('rise_training', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('podcast', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock()), ('url', wagtail.core.blocks.URLBlock())])), ('competence', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock())])), ('exercise', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock())])), ('self_evaluation', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock())])), ('document', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock())])), ('knowledge', wagtail.core.blocks.StructBlock([('description', wagtail.core.blocks.TextBlock())]))])), + ('contents', wagtail.fields.StreamField([('video', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('rise_training', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('podcast', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('competence', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('exercise', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('self_evaluation', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('document', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())]))])), ], options={ 'verbose_name': 'Learning Unit', diff --git a/server/vbv_lernwelt/learnpath/models.py b/server/vbv_lernwelt/learnpath/models.py index 326e6ebc..60e9ddac 100644 --- a/server/vbv_lernwelt/learnpath/models.py +++ b/server/vbv_lernwelt/learnpath/models.py @@ -1,11 +1,10 @@ # Create your models here. from django.utils.text import slugify -from grapple.helpers import register_query_field from wagtail.api import APIField -from wagtail.core.blocks import StreamBlock -from wagtail.core.fields import StreamField -from wagtail.core.models import Page, Orderable +from wagtail.blocks import StreamBlock +from wagtail.fields import StreamField +from wagtail.models import Page, Orderable from vbv_lernwelt.learnpath.models_competences import * from vbv_lernwelt.learnpath.models_learning_unit_content import RiseTrainingBlock, VideoBlock, PodcastBlock, \ @@ -13,7 +12,6 @@ from vbv_lernwelt.learnpath.models_learning_unit_content import RiseTrainingBloc from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class -@register_query_field("learning_path") class LearningPath(Page): # PageChooserPanel('related_page', 'demo.PublisherPage'), diff --git a/server/vbv_lernwelt/learnpath/models_competences.py b/server/vbv_lernwelt/learnpath/models_competences.py index f7d70107..d90f7a2f 100644 --- a/server/vbv_lernwelt/learnpath/models_competences.py +++ b/server/vbv_lernwelt/learnpath/models_competences.py @@ -1,7 +1,7 @@ from django.db import models -from wagtail.core.models import Page, Orderable +from wagtail.models import Page, Orderable from modelcluster.fields import ParentalKey -from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePanel +from wagtail.admin.panels import FieldPanel, StreamFieldPanel, InlinePanel class CompetencePage(Page): diff --git a/server/vbv_lernwelt/learnpath/models_learning_unit_content.py b/server/vbv_lernwelt/learnpath/models_learning_unit_content.py index 5b29f647..b14742f9 100644 --- a/server/vbv_lernwelt/learnpath/models_learning_unit_content.py +++ b/server/vbv_lernwelt/learnpath/models_learning_unit_content.py @@ -1,4 +1,4 @@ -from wagtail.core import blocks +from wagtail import blocks class VideoBlock(blocks.StructBlock): diff --git a/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py b/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py index e1a36f1a..c335779b 100644 --- a/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py +++ b/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py @@ -1,6 +1,6 @@ import wagtail_factories from django.conf import settings -from wagtail.core.models import Site, Page +from wagtail.models import Site, Page from vbv_lernwelt.core.admin import User from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningUnit diff --git a/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py b/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py index bbe0be8f..16e33fe5 100644 --- a/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py +++ b/server/vbv_lernwelt/learnpath/tests/test_create_default_learning_path.py @@ -1,6 +1,6 @@ from django.conf import settings from django.test import TestCase -from wagtail.core.models import Locale +from wagtail.models import Locale from vbv_lernwelt.learnpath.models import LearningPath from vbv_lernwelt.learnpath.tests.create_default_learning_path import create_default_learning_path