Skip to content

Commit

Permalink
Merge branch 'release/8.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
marteinn committed Jun 1, 2022
2 parents 3bcc650 + 0b744dc commit a8d6f81
Show file tree
Hide file tree
Showing 79 changed files with 1,111 additions and 1,057 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
cd Company-Project
chmod +x src/docker-entrypoint.sh
docker-compose -f docker-compose-circleci.yml build
- name: Verify backend scaffolder
run: |
cd Company-Project
set -x
docker-compose -f docker-compose-circleci.yml run --rm python python manage.py new_page --name=Article
- name: Run tests on container
run: |
cd Company-Project
Expand All @@ -56,7 +61,7 @@ jobs:
- uses: actions/checkout@master
- uses: "actions/setup-node@v2"
with:
node-version: "12"
node-version: "16"
- run: rm -rf Company-Project
- name: Restore generated-project
uses: actions/download-artifact@v2
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [8.8.0] - 2022-06-01

### Changed
- Upgrade to Wagtail 3 (@marteinn)
- Clarify SLACK_DEFAULT_CHANNEL value when setting up circle ci integration with slack (@marteinn)
- Add mypy linting for django-rest-framework parts (@marteinn)

## Fixed
- Improve page not found test by using proper json to detect component name (@marteinn)
- Cleanup unused imports and variable declarations (@marteinn)
- Run `manage.py new_page` on CI (@marteinn)
- Update django-stubs to 1.11.0
- Update sentry_sdk to 1.5.12
- Update @babel/core to 7.17.10
- Update @swc/core to 1.2.196
- Update @swc/jest to 0.2.21
- Update i18next to 21.8.5
- Update @sentry/nextjs to 7.0.0
- Update @testing-library/user-event to 14.2.0
- Update husky to 8.0.1

## [8.7.0] - 2022-05-07
### Added
- Add custom 502 page to Nginx (Andreas Bernacca)
Expand Down
850 changes: 422 additions & 428 deletions Company-Project/frontend/package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions Company-Project/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"test:ci": "npx jest --ci --runInBand --reporters=default --reporters=jest-junit"
},
"dependencies": {
"@sentry/nextjs": "^6.19.7",
"@sentry/nextjs": "^7.0.0",
"@types/react": "^17.0.38",
"classnames": "^2.3.1",
"i18next": "^21.7.1",
"i18next": "^21.8.5",
"next": "12.1.6",
"next-compose-plugins": "^2.2.1",
"prop-types": "^15.8.1",
Expand Down Expand Up @@ -54,18 +54,18 @@
"@storybook/manager-webpack5": "^6.4.22",
"@storybook/react": "^6.4.22",
"@svgr/webpack": "^6.2.1",
"@swc/core": "^1.2.177",
"@swc/jest": "^0.2.20",
"@swc/core": "^1.2.196",
"@swc/jest": "^0.2.21",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^14.1.1",
"@testing-library/user-event": "^14.2.0",
"babel-loader": "^8.2.5",
"babel-plugin-transform-dynamic-import": "^2.1.0",
"cross-env": "^7.0.3",
"css-loader": "^6.7.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"husky": "^7.0.4",
"husky": "^8.0.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^28.1.0",
"jest-junit": "^13.2.0",
Expand All @@ -76,3 +76,4 @@
"style-loader": "^3.3.1"
}
}

4 changes: 2 additions & 2 deletions Company-Project/src/customdocument/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import wagtail.core.models
import wagtail.models
import wagtail.search.index


Expand Down Expand Up @@ -40,7 +40,7 @@ class Migration(migrations.Migration):
(
"collection",
models.ForeignKey(
default=wagtail.core.models.get_root_collection_id,
default=wagtail.models.get_root_collection_id,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="wagtailcore.Collection",
Expand Down
3 changes: 3 additions & 0 deletions Company-Project/src/customdocument/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class CustomDocumentSerializer(serializers.ModelSerializer):
id = serializers.SerializerMethodField()
href = serializers.SerializerMethodField()

_mocked_id: int
_mocked_url: str

def get_id(self, obj):
if hasattr(self, "_mocked_id"):
return self._mocked_id
Expand Down
5 changes: 2 additions & 3 deletions Company-Project/src/customimage/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-04 12:44
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import wagtail.core.models
import wagtail.models
import wagtail.images.models
import wagtail.search.index

Expand Down Expand Up @@ -66,7 +65,7 @@ class Migration(migrations.Migration):
(
"collection",
models.ForeignKey(
default=wagtail.core.models.get_root_collection_id,
default=wagtail.models.get_root_collection_id,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="wagtailcore.Collection",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-25 15:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('customimage', '0002_customimage_file_hash'),
]

operations = [
migrations.AlterField(
model_name='customimage',
name='file_hash',
field=models.CharField(blank=True, db_index=True, editable=False, max_length=40),
),
]
11 changes: 9 additions & 2 deletions Company-Project/src/customimage/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List, Optional

from rest_framework import serializers
from wagtail.images.shortcuts import get_rendition_or_not_found

Expand All @@ -10,13 +12,18 @@ class CustomImageSerializer(serializers.ModelSerializer):
id = serializers.SerializerMethodField()
focal = serializers.SerializerMethodField()

def get_id(self, obj):
_mocked_id: int
_mocked_url: str
_mocked_renditions: List
_renditions: List

def get_id(self, obj) -> int:
if hasattr(self, "_mocked_id"):
return self._mocked_id

return obj.pk

def get_url(self, obj):
def get_url(self, obj) -> Optional[str]:
if hasattr(self, "_mocked_url"):
return self._mocked_url

Expand Down
4 changes: 2 additions & 2 deletions Company-Project/src/main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import main.mixins
from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.fields
import wagtail.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -37,7 +37,7 @@ class Migration(migrations.Migration):
name='ArticlePage',
fields=[
('basepage_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='main.BasePage')),
('rich_text', wagtail.core.fields.RichTextField(blank=True, null=True, verbose_name='Rich text')),
('rich_text', wagtail.fields.RichTextField(blank=True, null=True, verbose_name='Rich text')),
],
options={
'verbose_name': 'Article',
Expand Down
27 changes: 13 additions & 14 deletions Company-Project/src/main/mixins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Any, Optional, Callable, List, Tuple, Union
from typing import Any, Callable, Dict, List, Tuple, Type, Union

from django.db import models
from django.http import JsonResponse
Expand All @@ -7,17 +7,16 @@
from django.utils.translation import gettext_lazy as _
from django.utils.functional import cached_property
from rest_framework.serializers import Serializer
from wagtail.admin.edit_handlers import (
BaseFormEditHandler,
from wagtail.admin.panels import (
EditHandler,
FieldPanel,
MultiFieldPanel,
ObjectList,
PanelGroup,
TabbedInterface,
WagtailAdminPageForm,
)
from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.models import Page
from wagtail.utils.decorators import cached_classmethod
from wagtail_meta_preview.panels import (
FacebookFieldPreviewPanel,
Expand Down Expand Up @@ -129,15 +128,15 @@ class SeoMixin(Page):
[
FieldPanel("og_title"),
FieldPanel("og_description"),
ImageChooserPanel("og_image"),
FieldPanel("og_image"),
],
heading=_("Facebook"),
),
TwitterFieldPreviewPanel(
[
FieldPanel("twitter_title"),
FieldPanel("twitter_description"),
ImageChooserPanel("twitter_image"),
FieldPanel("twitter_image"),
],
heading=_("Twitter"),
),
Expand Down Expand Up @@ -226,7 +225,7 @@ class Meta:


class EnhancedEditHandlerMixin:
edit_handler: BaseFormEditHandler
edit_handler: PanelGroup
content_panels: List[EditHandler]
promote_panels: List[EditHandler]
settings_panels: List[EditHandler]
Expand All @@ -241,7 +240,7 @@ def get_edit_handler(cls) -> EditHandler:
"""

if hasattr(cls, "edit_handler"):
return cls.edit_handler.bind_to(model=cls)
return cls.edit_handler.bind_to_model(cls)

# construct a TabbedInterface made up of content_panels, promote_panels
# and settings_panels, skipping any which are empty
Expand All @@ -268,7 +267,7 @@ def get_edit_handler(cls) -> EditHandler:

EditHandler = TabbedInterface(tabs, base_form_class=cls.base_form_class)

return EditHandler.bind_to(model=cls)
return EditHandler.bind_to_model(cls)


class TimestampMixin(models.Model):
Expand All @@ -282,27 +281,27 @@ class Meta:
class ReactViewMixin(object):
request: HttpRequest
component_name: str
serializer_class: Union[str, Serializer]
serializer_class: Union[str, Type[Serializer]]

def render_to_response(self, context, **response_kwargs):
props = self.get_component_data({"request": self.request})
return JsonResponse(props)

def get_component_data(self, context: Optional[Dict]) -> Dict[str, Any]:
def get_component_data(self, context: Dict) -> Dict[str, Any]:
return {
"component_name": self.component_name,
"component_props": self.to_dict(context),
}

def to_dict(self, context: Optional[Dict]) -> Dict[str, Any]:
def to_dict(self, context: Dict[Any, Any]) -> Dict[str, Any]:
serializer_cls = self.get_serializer_class()
serializer = serializer_cls(
self.get_component_props(), context=context,
)

return serializer.data

def get_serializer_class(self) -> Serializer:
def get_serializer_class(self) -> Type[Serializer]:
if isinstance(self.serializer_class, str):
return import_string(self.serializer_class)

Expand Down
6 changes: 3 additions & 3 deletions Company-Project/src/main/pages/article.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.utils.translation import gettext_lazy as _
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import RichTextFieldPanel
from wagtail.fields import RichTextField
from wagtail.admin.panels import FieldPanel
from wagtail_headless_preview.models import HeadlessPreviewMixin

from .base import BasePage
Expand All @@ -9,7 +9,7 @@
class ArticlePage(HeadlessPreviewMixin, BasePage):
rich_text = RichTextField(blank=True, null=True, verbose_name=_("Rich text"))

content_panels = BasePage.content_panels + [RichTextFieldPanel("rich_text")]
content_panels = BasePage.content_panels + [FieldPanel("rich_text")]

extra_panels = BasePage.extra_panels
serializer_class = "main.pages.ArticlePageSerializer"
Expand Down
2 changes: 1 addition & 1 deletion Company-Project/src/main/pages/article_serializer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from rest_framework import serializers
from wagtail.core.rich_text import expand_db_html
from wagtail.rich_text import expand_db_html

from .base_serializer import BasePageSerializer
from . import ArticlePage
Expand Down
24 changes: 15 additions & 9 deletions Company-Project/src/main/pages/base.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from typing import List, Dict, Any, Optional, Union, Tuple
from typing import List, Dict, Any, Optional, Union, Tuple, Type

from django.utils.module_loading import import_string
from django.http import HttpResponse, JsonResponse
from django.http.request import HttpRequest
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.core.models import Page
from wagtail_headless_preview.models import HeadlessPreviewMixin
from wagtail.models import Page

from ..mixins import EnhancedEditHandlerMixin, SeoMixin

Expand Down Expand Up @@ -36,7 +35,7 @@ def get_component_data(
self,
context: Optional[Dict],
component_name: Optional[str] = None,
serializer_cls: Optional[Union[str, Serializer]] = None,
serializer_cls: Optional[Union[str, Type[Serializer]]] = None,
) -> Dict[str, Any]:
return {
"component_name": component_name or self.component_name,
Expand All @@ -46,16 +45,23 @@ def get_component_data(
def to_dict(
self,
context: Optional[Dict],
serializer_cls: Optional[Union[str, Serializer]] = None,
serializer_cls: Optional[Union[str, Type[Serializer]]] = None,
) -> Dict[str, Any]:
context = context or {}
dict_serializer_cls: Optional[Type[Serializer]]

if isinstance(serializer_cls, str):
serializer_cls = import_string(self.serializer_class)
serializer_cls = serializer_cls or self.get_serializer_class()
serializer = serializer_cls(self, context=context)
dict_serializer_cls = import_string(self.serializer_class)
else:
dict_serializer_cls = self.get_serializer_class()

if not dict_serializer_cls:
raise Exception("Serializer not found")

serializer = dict_serializer_cls(self, context=context)
return serializer.data

def get_serializer_class(self) -> Serializer:
def get_serializer_class(self) -> Type[Serializer]:
return import_string(self.serializer_class)

def get_preview_url(self, token):
Expand Down
3 changes: 1 addition & 2 deletions Company-Project/src/main/pages/base_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from rest_framework import serializers
from wagtail.admin.templatetags.wagtailuserbar import wagtailuserbar
from wagtail.core import fields
from wagtail.core.models import Locale
from wagtail import fields
from wagtail.api.v2 import serializers as wagtail_serializers

from sitesettings.models import SiteSetting
Expand Down
Loading

0 comments on commit a8d6f81

Please sign in to comment.