Skip to content

Commit

Permalink
Merge pull request #1082 from uktrade/develop
Browse files Browse the repository at this point in the history
UAT/Prod Release
  • Loading branch information
davidu1975 authored May 10, 2023
2 parents 344b4e4 + 69dca2d commit f509424
Show file tree
Hide file tree
Showing 83 changed files with 934 additions and 602 deletions.
2 changes: 1 addition & 1 deletion components/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ExclusivePageMixin,
ServiceMixin,
)
from wagtail.admin.edit_handlers import (
from wagtail.admin.panels import (
FieldPanel, MultiFieldPanel
)
from core.mixins import ServiceNameUniqueSlugMixin
Expand Down
3 changes: 2 additions & 1 deletion conf/env/dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ SECURE_SSL_REDIRECT=false
HEALTH_CHECK_TOKEN=debug
SIGNATURE_SECRET=debug
BASE_URL=cms.trade.great
DB_NAME=directory_cms_debug
WAGTAILADMIN_BASE_URL=cms.trade.great
DB_NAME=directory_cms_debugx
DB_USER=debug
DB_PASSWORD=debug
DATABASE_URL=postgres://debug:debug@localhost:5432/directory_cms_debug
Expand Down
14 changes: 12 additions & 2 deletions conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail',
'wagtail.api.v2',
'wagtail.sites',
'modelcluster',
Expand Down Expand Up @@ -353,10 +353,20 @@

WAGTAIL_SITE_NAME = 'directory-cms'
WAGTAIL_PASSWORD_RESET_ENABLED = False
WAGTAILMEDIA_MEDIA_MODEL = 'core.GreatMedia'

WAGTAILMEDIA = {
"MEDIA_MODEL": "core.GreatMedia", # string, dotted-notation. Defaults to "wagtailmedia.Media"
"MEDIA_FORM_BASE": "", # string, dotted-notation. Defaults to an empty string
"AUDIO_EXTENSIONS": [], # list of extensions
"VIDEO_EXTENSIONS": [], # list of extensions
}


# WAGTAILMEDIA_MEDIA_MODEL = 'core.GreatMedia'
WAGTAIL_EMAIL_MANAGEMENT_ENABLED = False

BASE_URL = env.str('BASE_URL')
WAGTAILADMIN_BASE_URL = env.str('BASE_URL')

APP_URL_EXPORT_READINESS = env.str('APP_URL_EXPORT_READINESS')
APP_URL_GREAT_INTERNATIONAL = env.str('APP_URL_GREAT_INTERNATIONAL')
Expand Down
2 changes: 1 addition & 1 deletion conf/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib import admin
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.api.v2.router import WagtailAPIRouter
from wagtail.core import urls as wagtail_urls
from wagtail import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls

from django.conf.urls import include, url
Expand Down
2 changes: 1 addition & 1 deletion core/blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.core import blocks
from wagtail import blocks
from wagtail.images.blocks import ImageChooserBlock
from wagtailmedia.blocks import AbstractMediaChooserBlock

Expand Down
4 changes: 2 additions & 2 deletions core/blocks_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from rest_framework import serializers
from rest_framework.fields import SkipField
from rest_framework.relations import PKOnlyObject
from wagtail.core.blocks import StructValue
from wagtail.blocks import StructValue
from wagtail.images.api import fields as wagtail_fields


class StreamChildBaseSerializer(serializers.Serializer):

def to_representation(self, stream_child):
"""
instance is wagtail.core.blocks.stream_block.StreamValue.StreamChild
instance is wagtail.blocks.stream_block.StreamValue.StreamChild
instance.value is either an instance of StructValue, if struct block, or a single value
"""
ret = OrderedDict()
Expand Down
4 changes: 2 additions & 2 deletions core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from directory_constants import cms, slugs
from rest_framework.renderers import JSONRenderer
from wagtail.core.signals import page_published, page_unpublished
from wagtail.core.models import Page, Site
from wagtail.signals import page_published, page_unpublished
from wagtail.models import Page, Site

from django.conf import settings
from django.core.cache import cache
Expand Down
5 changes: 3 additions & 2 deletions core/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import fields
from wagtail.core import blocks
from wagtail.core.fields import StreamField
from wagtail import blocks
from wagtail.fields import StreamField

from conf import settings
from core import helpers, models
Expand Down Expand Up @@ -99,5 +99,6 @@ def single_struct_block_stream_field_factory(
min_num=min_num,
required=required
),
use_json_field=True,
**kwargs)
return field
2 changes: 1 addition & 1 deletion core/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import django_filters
from django.contrib.contenttypes.models import ContentType
from wagtail.core.models import PAGE_MODEL_CLASSES, Page
from wagtail.models import PAGE_MODEL_CLASSES, Page


class ServiceNameFilter(django_filters.FilterSet):
Expand Down
6 changes: 3 additions & 3 deletions core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

from bleach_whitelist import markdown_tags, markdown_attrs
from modeltranslation.utils import build_localized_fieldname
from wagtail.admin.edit_handlers import ObjectList, TabbedInterface
from wagtail.core import hooks
from wagtail.core.models import Page
from wagtail.admin.panels import ObjectList, TabbedInterface
from wagtail import hooks
from wagtail.models import Page
from wagtail.documents.models import Document
from wagtail.images.models import Image

Expand Down
2 changes: 1 addition & 1 deletion core/management/commands/enable_tree_based_routing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from directory_constants import cms
from django.core.management import BaseCommand
from django.core.management.base import no_translations
from wagtail.core.models import Page
from wagtail.models import Page

from core import filters

Expand Down
2 changes: 1 addition & 1 deletion core/management/commands/list_slug_links.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.core.management import BaseCommand
from django.core.management.base import no_translations
from wagtail.core.models import Page
from wagtail.models import Page

from django.forms.models import model_to_dict
from django.urls import reverse
Expand Down
2 changes: 1 addition & 1 deletion core/mixins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.core.models import Page
from wagtail.models import Page

from django.core.exceptions import ValidationError
from django.db import transaction
Expand Down
15 changes: 9 additions & 6 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from modeltranslation import settings as modeltranslation_settings
from modeltranslation.utils import build_localized_fieldname
from modeltranslation.translator import translator
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import BaseSetting, register_setting
from wagtail.core.models import Page, PageBase, Site
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
from wagtail.models import Page, PageBase, Site

from django.core import signing
from django.conf import settings
Expand Down Expand Up @@ -90,7 +90,7 @@ class Breadcrumb(models.Model):


@register_setting
class RoutingSettings(BaseSetting):
class RoutingSettings(BaseSiteSetting):
root_path_prefix = models.CharField(
blank=True,
max_length=100,
Expand Down Expand Up @@ -151,6 +151,9 @@ class Meta:
# overrides page.slug when generating the url
slug_override = None

# remove preview from all pages
preview_modes = []

subpage_types = []
content_panels = []
promote_panels = []
Expand Down Expand Up @@ -338,15 +341,15 @@ def serve(self, request, *args, **kwargs):
return redirect(self.get_url())

def get_latest_nested_revision_as_page(self):
revision = self.get_latest_revision_as_page()
revision = self.get_latest_revision_as_object()
foreign_key_names = [
field.name for field in revision._meta.get_fields()
if isinstance(field, models.ForeignKey)
]
for name in foreign_key_names:
field = getattr(revision, name)
if hasattr(field, 'get_latest_revision_as_page'):
setattr(revision, name, field.get_latest_revision_as_page())
setattr(revision, name, field.get_latest_revision_as_object())
return revision

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion core/panels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtail.admin.panels import FieldPanel, MultiFieldPanel


class SearchEngineOptimisationPanel(MultiFieldPanel):
Expand Down
2 changes: 1 addition & 1 deletion core/serializer_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

MODELS_SERIALIZERS_MAPPING = {
# core page
wagtail.core.models.Page: core.serializers.WagtailPageSerializer,
wagtail.models.Page: core.serializers.WagtailPageSerializer,

# Atlas core
# ----------
Expand Down

This file was deleted.

This file was deleted.

19 changes: 12 additions & 7 deletions core/templates/wagtailadmin/shared/field.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{% load wagtailadmin_tags %}
{% load core_tags %}
<div class="field {{ field|fieldtype }} {{ field|widgettype }} {{ field_classes }}{% if field.field.widget.attrs.required_for_language %}required-for-language-container{% endif %}">
{% if show_label|default_if_none:True %}{{ field.label_tag }}{% endif %}
<div class="field-content">
<div class="input {{ input_classes }} ">
{% block form_field %}
{{ field|render_with_errors }}
{% if field|can_render %}
{{ field|render_with_errors }}
{% endif %}
{% endblock %}

{# This span only used on rare occasions by certain types of input #}
Expand All @@ -14,12 +17,14 @@
<p class="help">{{ field.help_text }}</p>
{% endif %}

{% if field|has_unrendered_errors %}
<p class="error-message">
{% for error in field.errors %}
<span>{{ error|escape }}</span>
{% endfor %}
</p>
{% if field|can_render %}
{% if field|has_unrendered_errors %}
<p class="error-message">
{% for error in field.errors %}
<span>{{ error|escape }}</span>
{% endfor %}
</p>
{% endif %}
{% endif %}
</div>
</div>
Empty file added core/templatetags/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions core/templatetags/core_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django import template


register = template.Library()


@register.filter("can_render")
def can_render(bound_field):
return hasattr(bound_field, 'field')
2 changes: 1 addition & 1 deletion core/upstream_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import date, datetime
import json

from wagtail.core.models import Page
from wagtail.models import Page
from wagtail.documents.models import Document
from wagtail.images.models import Image

Expand Down
4 changes: 2 additions & 2 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from rest_framework.response import Response
from rest_framework.views import APIView
from wagtail.admin.api.views import PagesAdminAPIViewSet
from wagtail.core.models import Orderable, Page, Site
from wagtail.models import Orderable, Page, Site

from core.models import GreatMedia

Expand Down Expand Up @@ -370,7 +370,7 @@ def get_context_data(self, form):
instance=self.page,
parent_page=self.parent_page,
)
edit_handler = edit_handler.bind_to(
edit_handler = edit_handler.get_bound_panel(
instance=self.page,
form=form,
request=self.request
Expand Down
9 changes: 5 additions & 4 deletions core/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from wagtail.admin.widgets import Button, PageListingButton
from wagtail.core import hooks
from wagtail import hooks
from wagtail.admin.wagtail_hooks import page_listing_buttons

from django.conf import settings
Expand Down Expand Up @@ -27,11 +27,12 @@ def add_copy_button(page, page_perms, next_url=None, is_parent=False):


@helpers.replace_hook('register_page_listing_buttons', page_listing_buttons)
def update_default_listing_buttons(page, page_perms, next_url=None, is_parent=False):
buttons = list(page_listing_buttons(page, page_perms, next_url, is_parent))
def update_default_listing_buttons(page, page_perms, next_url=None, button_url_name=None):
buttons = list(page_listing_buttons(page, page_perms, next_url))
if isinstance(page, models.BasePage):
for button in buttons:
if helpers.get_button_url_name(button) == 'view_draft':
if (button_url_name and button_url_name == 'view_draft') or \
helpers.get_button_url_name(button) == 'view_draft':
button.url = page.get_url(is_draft=True)

else:
Expand Down
Loading

0 comments on commit f509424

Please sign in to comment.