From d02afcf501eee306f35f2eae657babbb31dfaad1 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Tue, 7 Jun 2022 14:43:01 +0200 Subject: [PATCH 1/3] Redirect to sorted cms index page --- client/src/router/index.ts | 3 + client/src/views/404View.vue | 15 ++- client/src/views/CircleView.vue | 2 +- client/src/views/HomeView.vue | 2 +- client/src/views/StyelGuideView.vue | 8 +- prepare_server.sh | 5 + prepare_server_cypress.sh | 5 + server/config/settings/base.py | 3 - .../templates/learnpath/circle.html | 112 ++---------------- .../templates/wagtailadmin/pages/index.html | 14 +++ 10 files changed, 54 insertions(+), 115 deletions(-) create mode 100644 server/vbv_lernwelt/templates/wagtailadmin/pages/index.html diff --git a/client/src/router/index.ts b/client/src/router/index.ts index f821c851..1342c3e2 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -38,6 +38,9 @@ const router = createRouter({ { path: '/styleguide', component: () => import('../views/StyelGuideView.vue'), + meta: { + public: true + } }, { path: '/:pathMatch(.*)*', diff --git a/client/src/views/404View.vue b/client/src/views/404View.vue index 4437a8d1..d6a6a096 100644 --- a/client/src/views/404View.vue +++ b/client/src/views/404View.vue @@ -1,11 +1,18 @@ + + + - - diff --git a/client/src/views/CircleView.vue b/client/src/views/CircleView.vue index 7912e36d..1edf5a73 100644 --- a/client/src/views/CircleView.vue +++ b/client/src/views/CircleView.vue @@ -77,7 +77,7 @@ export default {
-
+

{{ circleData.title }}

diff --git a/client/src/views/HomeView.vue b/client/src/views/HomeView.vue index 7fb5eee8..51752302 100644 --- a/client/src/views/HomeView.vue +++ b/client/src/views/HomeView.vue @@ -7,7 +7,7 @@ import MainNavigationBar from '@/components/MainNavigationBar.vue';

myVBV Start Page

-
+
Styelguide Login Circle "Analyse" (Login benötigt) diff --git a/client/src/views/StyelGuideView.vue b/client/src/views/StyelGuideView.vue index 731bf25f..204fb30c 100644 --- a/client/src/views/StyelGuideView.vue +++ b/client/src/views/StyelGuideView.vue @@ -41,7 +41,7 @@ function colorBgClass(color: string, value: number) {

Icons

-
+
IconMessage @@ -95,7 +95,7 @@ function colorBgClass(color: string, value: number) {
-
+
IconLsApply @@ -132,7 +132,7 @@ function colorBgClass(color: string, value: number) {
-
+
IconSmileyHappy @@ -188,7 +188,7 @@ function colorBgClass(color: string, value: number) {

Buttons

-
+
Primary Link diff --git a/prepare_server.sh b/prepare_server.sh index 81a13cf0..b9d2fc36 100755 --- a/prepare_server.sh +++ b/prepare_server.sh @@ -1,5 +1,8 @@ #!/bin/bash +# set location to script directory +cd "${0%/*}" + if [ -z "$CI" ]; then # kill all subprocess on exit so that Bitbucket Pipelines process will not hang @@ -46,6 +49,8 @@ mypsql() { if [ "$SKIP_SETUP" = false ]; then # TODO: in heroku we must do a `pg:resets` to reset the db + echo "Check postgres connection" + mypsql -c "SELECT 1" echo "Drop all connections to $POSTGRES_DB" mypsql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$POSTGRES_DB' AND pid <> pg_backend_pid();" > /dev/null 2>&1 echo "Drop database: $POSTGRES_DB" diff --git a/prepare_server_cypress.sh b/prepare_server_cypress.sh index fa2e45ce..f8fb3dd3 100755 --- a/prepare_server_cypress.sh +++ b/prepare_server_cypress.sh @@ -1,3 +1,8 @@ +#!/bin/bash + +# set location to script directory +cd "${0%/*}" + export IT_APP_ENVIRONMENT=development export DJANGO_SETTINGS_MODULE=config.settings.test_cypress export DJANGO_PORT=8001 diff --git a/server/config/settings/base.py b/server/config/settings/base.py index 15a65c39..91369c6a 100644 --- a/server/config/settings/base.py +++ b/server/config/settings/base.py @@ -80,9 +80,6 @@ THIRD_PARTY_APPS = [ "drf_spectacular", "django_htmx", - "grapple", - "graphene_django", - 'wagtail.contrib.forms', 'wagtail.contrib.redirects', 'wagtail.embeds', diff --git a/server/vbv_lernwelt/templates/learnpath/circle.html b/server/vbv_lernwelt/templates/learnpath/circle.html index 057b190d..7fac7fec 100644 --- a/server/vbv_lernwelt/templates/learnpath/circle.html +++ b/server/vbv_lernwelt/templates/learnpath/circle.html @@ -1,104 +1,12 @@ {% extends "base.html" %} -{% load wagtailcore_tags %} - -{% block body_class %}template-cicle{% endblock %} - -{% block content %} -
-
- - -
- - - - - - - - -
-

{{ page.title }}

-
{{ page.description }}
-
{{ page.goals }}
-
- -
- {% for learning_sequence in page.learning_sequences.all %} -
-

{{ learning_sequence.title }}

- {% for learning_unit in learning_sequence.learning_units.all %} - - {% endfor %} -
- {% endfor %} -
-
- - -{% endblock %} +{% block inline_javascript %} + +{% endblock inline_javascript %} diff --git a/server/vbv_lernwelt/templates/wagtailadmin/pages/index.html b/server/vbv_lernwelt/templates/wagtailadmin/pages/index.html new file mode 100644 index 00000000..337de9c8 --- /dev/null +++ b/server/vbv_lernwelt/templates/wagtailadmin/pages/index.html @@ -0,0 +1,14 @@ +{% extends "wagtailadmin/pages/index.html" %} +{% load wagtailadmin_tags i18n %} + +{% block extra_js %} + {{ block.super }} + + +{% endblock %} From 3a9ad53e7a667c9608efe803c27404538630a3c7 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Tue, 7 Jun 2022 18:16:53 +0200 Subject: [PATCH 2/3] 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 From d88d44ecb06645bb77f2b8cf04bbf26467d61ed1 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Wed, 8 Jun 2022 11:59:09 +0200 Subject: [PATCH 3/3] Refactor icons as Web Components --- client/index.html | 1 + .../components/circle/LearningSequence.vue | 7 +- client/src/components/icons/IconArrowDown.vue | 7 -- client/src/components/icons/IconArrowLeft.vue | 7 -- .../src/components/icons/IconArrowRight.vue | 7 -- client/src/components/icons/IconArrowUp.vue | 7 -- client/src/components/icons/IconCheck.vue | 7 -- .../components/icons/IconCheckboxChecked.vue | 7 -- .../icons/IconCheckboxUnchecked.vue | 5 - client/src/components/icons/IconClose.vue | 7 -- client/src/components/icons/IconLsApply.vue | 7 -- client/src/components/icons/IconLsEnd.vue | 10 -- client/src/components/icons/IconLsNetwork.vue | 14 --- .../src/components/icons/IconLsPractice.vue | 7 -- client/src/components/icons/IconLsTest.vue | 7 -- client/src/components/icons/IconLsWatch.vue | 7 -- client/src/components/icons/IconMessage.vue | 7 -- .../src/components/icons/IconSmileyHappy.vue | 14 --- .../components/icons/IconSmileyNeutral.vue | 13 --- .../components/icons/IconSmileyThinking.vue | 21 ---- client/src/main.ts | 17 --- client/src/views/StyelGuideView.vue | 103 ++++++++---------- client/vite.config.ts | 18 ++- server/vbv_lernwelt/learnpath/urls.py | 8 +- server/vbv_lernwelt/learnpath/views.py | 27 +++++ .../templates/simpletodo/index.html | 5 + .../static/icons/icon-arrow-down.svg | 5 + .../static/icons/icon-arrow-left.svg | 5 + .../static/icons/icon-arrow-right.svg | 5 + .../static/icons/icon-arrow-up.svg | 5 + .../vbv_lernwelt/static/icons/icon-check.svg | 5 + .../static/icons/icon-checkbox-checked.svg | 5 + .../static/icons/icon-checkbox-unchecked.svg | 3 + .../vbv_lernwelt/static/icons/icon-close.svg | 5 + .../vbv_lernwelt/static/icons/icon-info.svg | 7 +- .../static/icons/icon-ls-apply.svg | 5 + .../vbv_lernwelt/static/icons/icon-ls-end.svg | 8 ++ .../static/icons/icon-ls-network.svg | 12 ++ .../static/icons/icon-ls-practice.svg | 5 + .../static/icons/icon-ls-start.svg | 8 +- .../static/icons/icon-ls-test.svg | 5 + .../static/icons/icon-ls-watch.svg | 5 + .../static/icons/icon-message.svg | 5 + .../static/icons/icon-smiley-happy.svg | 12 ++ .../static/icons/icon-smiley-neutral.svg | 11 ++ .../static/icons/icon-smiley-thinking.svg | 18 +++ server/vbv_lernwelt/templates/base.html | 2 + .../vbv_lernwelt/templates/learnpath/icons.js | 29 +++++ 48 files changed, 254 insertions(+), 263 deletions(-) delete mode 100644 client/src/components/icons/IconArrowDown.vue delete mode 100644 client/src/components/icons/IconArrowLeft.vue delete mode 100644 client/src/components/icons/IconArrowRight.vue delete mode 100644 client/src/components/icons/IconArrowUp.vue delete mode 100644 client/src/components/icons/IconCheck.vue delete mode 100644 client/src/components/icons/IconCheckboxChecked.vue delete mode 100644 client/src/components/icons/IconCheckboxUnchecked.vue delete mode 100644 client/src/components/icons/IconClose.vue delete mode 100644 client/src/components/icons/IconLsApply.vue delete mode 100644 client/src/components/icons/IconLsEnd.vue delete mode 100644 client/src/components/icons/IconLsNetwork.vue delete mode 100644 client/src/components/icons/IconLsPractice.vue delete mode 100644 client/src/components/icons/IconLsTest.vue delete mode 100644 client/src/components/icons/IconLsWatch.vue delete mode 100644 client/src/components/icons/IconMessage.vue delete mode 100644 client/src/components/icons/IconSmileyHappy.vue delete mode 100644 client/src/components/icons/IconSmileyNeutral.vue delete mode 100644 client/src/components/icons/IconSmileyThinking.vue create mode 100644 server/vbv_lernwelt/static/icons/icon-arrow-down.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-arrow-left.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-arrow-right.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-arrow-up.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-check.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-checkbox-checked.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-checkbox-unchecked.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-close.svg rename client/src/components/icons/IconInfo.vue => server/vbv_lernwelt/static/icons/icon-info.svg (71%) create mode 100644 server/vbv_lernwelt/static/icons/icon-ls-apply.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-ls-end.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-ls-network.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-ls-practice.svg rename client/src/components/icons/IconLsStart.vue => server/vbv_lernwelt/static/icons/icon-ls-start.svg (70%) create mode 100644 server/vbv_lernwelt/static/icons/icon-ls-test.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-ls-watch.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-message.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-smiley-happy.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-smiley-neutral.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-smiley-thinking.svg create mode 100644 server/vbv_lernwelt/templates/learnpath/icons.js diff --git a/client/index.html b/client/index.html index 11f9aef5..31fdea1c 100644 --- a/client/index.html +++ b/client/index.html @@ -7,6 +7,7 @@ + myVBV diff --git a/client/src/components/circle/LearningSequence.vue b/client/src/components/circle/LearningSequence.vue index e1af43eb..3dd68457 100644 --- a/client/src/components/circle/LearningSequence.vue +++ b/client/src/components/circle/LearningSequence.vue @@ -1,8 +1,5 @@ @@ -31,8 +28,8 @@ defineProps(['learningSequence']) v-for="learningUnit in learningPackage.learningUnits" class="flex items-center gap-4 pb-3" > - - + +
{{ learningUnit.contents[0].type }}: {{ learningUnit.title }}
diff --git a/client/src/components/icons/IconArrowDown.vue b/client/src/components/icons/IconArrowDown.vue deleted file mode 100644 index 96f7b2d0..00000000 --- a/client/src/components/icons/IconArrowDown.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconArrowLeft.vue b/client/src/components/icons/IconArrowLeft.vue deleted file mode 100644 index eee84291..00000000 --- a/client/src/components/icons/IconArrowLeft.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconArrowRight.vue b/client/src/components/icons/IconArrowRight.vue deleted file mode 100644 index 907d78b1..00000000 --- a/client/src/components/icons/IconArrowRight.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconArrowUp.vue b/client/src/components/icons/IconArrowUp.vue deleted file mode 100644 index 1c9cc238..00000000 --- a/client/src/components/icons/IconArrowUp.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconCheck.vue b/client/src/components/icons/IconCheck.vue deleted file mode 100644 index db492cd1..00000000 --- a/client/src/components/icons/IconCheck.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconCheckboxChecked.vue b/client/src/components/icons/IconCheckboxChecked.vue deleted file mode 100644 index 79718f51..00000000 --- a/client/src/components/icons/IconCheckboxChecked.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconCheckboxUnchecked.vue b/client/src/components/icons/IconCheckboxUnchecked.vue deleted file mode 100644 index 0d84821c..00000000 --- a/client/src/components/icons/IconCheckboxUnchecked.vue +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/client/src/components/icons/IconClose.vue b/client/src/components/icons/IconClose.vue deleted file mode 100644 index bd32921e..00000000 --- a/client/src/components/icons/IconClose.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconLsApply.vue b/client/src/components/icons/IconLsApply.vue deleted file mode 100644 index 3c2dae05..00000000 --- a/client/src/components/icons/IconLsApply.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconLsEnd.vue b/client/src/components/icons/IconLsEnd.vue deleted file mode 100644 index 00aa08ce..00000000 --- a/client/src/components/icons/IconLsEnd.vue +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/client/src/components/icons/IconLsNetwork.vue b/client/src/components/icons/IconLsNetwork.vue deleted file mode 100644 index bcfb5d35..00000000 --- a/client/src/components/icons/IconLsNetwork.vue +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/client/src/components/icons/IconLsPractice.vue b/client/src/components/icons/IconLsPractice.vue deleted file mode 100644 index 940f9e26..00000000 --- a/client/src/components/icons/IconLsPractice.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconLsTest.vue b/client/src/components/icons/IconLsTest.vue deleted file mode 100644 index 050448d0..00000000 --- a/client/src/components/icons/IconLsTest.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconLsWatch.vue b/client/src/components/icons/IconLsWatch.vue deleted file mode 100644 index e2e3bb75..00000000 --- a/client/src/components/icons/IconLsWatch.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconMessage.vue b/client/src/components/icons/IconMessage.vue deleted file mode 100644 index 5bd94641..00000000 --- a/client/src/components/icons/IconMessage.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/client/src/components/icons/IconSmileyHappy.vue b/client/src/components/icons/IconSmileyHappy.vue deleted file mode 100644 index 5d6829bb..00000000 --- a/client/src/components/icons/IconSmileyHappy.vue +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/client/src/components/icons/IconSmileyNeutral.vue b/client/src/components/icons/IconSmileyNeutral.vue deleted file mode 100644 index c48f93c2..00000000 --- a/client/src/components/icons/IconSmileyNeutral.vue +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/client/src/components/icons/IconSmileyThinking.vue b/client/src/components/icons/IconSmileyThinking.vue deleted file mode 100644 index 990bef88..00000000 --- a/client/src/components/icons/IconSmileyThinking.vue +++ /dev/null @@ -1,21 +0,0 @@ - diff --git a/client/src/main.ts b/client/src/main.ts index 3707db7e..b0b3f535 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -5,14 +5,6 @@ import {setupI18n} from './i18n' import App from './App.vue' import router from './router' -import IconLsApply from '@/components/icons/IconLsApply.vue'; -import IconLsWatch from '@/components/icons/IconLsWatch.vue'; -import IconLsTest from '@/components/icons/IconLsTest.vue'; -import IconLsPractice from '@/components/icons/IconLsPractice.vue'; -import IconLsNetwork from '@/components/icons/IconLsNetwork.vue'; -import IconLsStart from '@/components/icons/IconLsStart.vue'; -import IconLsEnd from '@/components/icons/IconLsEnd.vue'; - import '@/assets/styles/index.scss' const i18n = setupI18n() @@ -26,12 +18,3 @@ app.use(router) app.use(i18n) app.mount('#app') - -// register icons globally -app.component('IconLsApply', IconLsApply) -app.component('IconLsWatch', IconLsWatch) -app.component('IconLsTest', IconLsTest) -app.component('IconLsPractice', IconLsPractice) -app.component('IconLsNetwork', IconLsNetwork) -app.component('IconLsStart', IconLsStart) -app.component('IconLsEnd', IconLsEnd) diff --git a/client/src/views/StyelGuideView.vue b/client/src/views/StyelGuideView.vue index 204fb30c..44ccd7ed 100644 --- a/client/src/views/StyelGuideView.vue +++ b/client/src/views/StyelGuideView.vue @@ -1,26 +1,6 @@ + {% block javascript %} diff --git a/server/vbv_lernwelt/templates/learnpath/icons.js b/server/vbv_lernwelt/templates/learnpath/icons.js new file mode 100644 index 00000000..f03cc06b --- /dev/null +++ b/server/vbv_lernwelt/templates/learnpath/icons.js @@ -0,0 +1,29 @@ +/* +create custom element classes from svg files +example: + +class icon_arrow_up extends HTMLElement { + connectedCallback() { + this.innerHTML = ` + + +`; + } +} + +customElements.define('it-icon-arrow-up', icon_arrow_up); +*/ + + +{% for svg_icon in svg_files %} + +class {{ svg_icon.classname }} extends HTMLElement { + connectedCallback() { + this.innerHTML = `{{ svg_icon.content|safe }}`; + } +} + +customElements.define('{{ svg_icon.elementname }}', {{ svg_icon.classname }}); + +{% endfor %}