Skip to content

Commit

Permalink
Merge branch 'main' into team-profile-complete
Browse files Browse the repository at this point in the history
  • Loading branch information
CamLamb committed Dec 4, 2024
2 parents 37a605f + 1edde98 commit 8055239
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,9 @@ FEEDBACK_NOTIFICATION_EMAIL_RECIPIENTS="[email protected],"
SEARCH_SHOW_INACTIVE_PROFILES_WITHIN_DAYS=90
# Manage apllication caching
SEARCH_ENABLE_QUERY_CACHE=False

# Django Silk
SILK_ENABLED=False

# Django Debug Toolbar
DDT_ENABLED=False
10 changes: 9 additions & 1 deletion assets/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ require.context("govuk-frontend/govuk/assets");
require.context(
"@ministryofjustice/frontend/moj/assets"
);
import {initAll} from "govuk-frontend";
import { initAll } from "govuk-frontend";
import mojFrontend from "@ministryofjustice/frontend";

initAll();
mojFrontend.initAll();

if (typeof window.djdt !== "undefined" && typeof window.htmx !== "undefined") {
htmx.on("htmx:afterSettle", function (detail) {
if (detail.target instanceof HTMLBodyElement) {
djdt.show_toolbar();
}
});
}
44 changes: 18 additions & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ wagtail-factories = "^4.0.0"
# Util
bpython = "^0.24"
django-extensions = "^3.2.1"
django-silk = "^5.0.4"
django-debug-toolbar = "^4.4.6"
werkzeug = "^3.0.6"
blessings = "^1.7"
pytest-mock = "^3.11.1"
pytest-freezer = "^0.4.8"
playwright = "^1.36"
django-silk = "^5.0.4"
snakeviz = "^2.2.0"
debugpy = "*"

Expand Down
17 changes: 14 additions & 3 deletions src/config/settings/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
]

try:
# Enable Django Debug Toolbar
DDT_ENABLED = env.bool("DDT_ENABLED", False) # noqa F405
if DDT_ENABLED:
INSTALLED_APPS += [
"debug_toolbar",
]
# Add the middleware to the top of the list.
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa F405
INTERNAL_IPS = [
"127.0.0.1",
]

SILK_ENABLED = env.bool("SILK_ENABLED", False) # noqa F405
if SILK_ENABLED:
# Add django-silk for profiling
import silk # noqa F401

Expand All @@ -35,8 +48,6 @@
"profiler_results",
)
SILKY_META = True
except ModuleNotFoundError:
...


DEV_TOOLS_ENABLED = env.bool("DEV_TOOLS_ENABLED", True) # noqa F405
Expand Down
6 changes: 6 additions & 0 deletions src/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@
urlpatterns += [
path("dev-tools/", include("dev_tools.urls", namespace="dev_tools"))
]
if "debug_toolbar" in settings.INSTALLED_APPS:
# Django Debug Toolbar purposefully only active with DEBUG=True
from debug_toolbar.toolbar import debug_toolbar_urls

urlpatterns += debug_toolbar_urls()

urlpatterns += [
# Wagtail
path("", include(wagtail_urls)),
]


# Removed until we find a fix for Wagtail's redirect behaviour
handler404 = "core.views.view_404"
handler500 = "core.views.view_500"
Expand Down
3 changes: 1 addition & 2 deletions src/content/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from django.utils.html import strip_tags
from simple_history.models import HistoricalRecords
from wagtail.admin.panels import (
FieldPanel,
InlinePanel,
ObjectList,
TabbedInterface,
TitleFieldPanel,
Expand All @@ -33,6 +31,7 @@
truncate_words_and_chars,
)
from content.validators import validate_description_word_count
from core.panels import FieldPanel, InlinePanel
from extended_search.index import DWIndexedField as IndexedField
from extended_search.index import Indexed, RelatedFields
from peoplefinder.widgets import PersonChooser
Expand Down
18 changes: 17 additions & 1 deletion src/core/panels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtail.admin.panels import PageChooserPanel
from wagtail.admin.panels import FieldPanel, InlinePanel, PageChooserPanel

from core.widgets import ReadOnlyPageInput

Expand All @@ -9,3 +9,19 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)
if self.instance and self.instance.pk:
self.bound_field.field.widget = ReadOnlyPageInput()


class FieldPanel(FieldPanel):
class BoundPanel(FieldPanel.BoundPanel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not self.bound_field.field.required:
self.heading += " (optional)"


class InlinePanel(InlinePanel):
class BoundPanel(InlinePanel.BoundPanel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.panel.min_num is None or self.panel.min_num == 0:
self.heading += " (optional)"
3 changes: 2 additions & 1 deletion src/country_fact_sheet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from django.contrib.auth import get_user_model
from django.db import models
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.admin.panels import MultiFieldPanel
from wagtail.documents.models import Document

from content.models import ContentPage
from core.panels import FieldPanel


UserModel = get_user_model()
Expand Down
3 changes: 2 additions & 1 deletion src/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.utils import timezone
from wagtail.admin.panels import FieldPanel, FieldRowPanel, MultiFieldPanel
from wagtail.admin.panels import FieldRowPanel, MultiFieldPanel
from wagtail.contrib.routable_page.models import RoutablePageMixin, route

from content.models import BasePage, ContentPage
from core.models import fields
from core.panels import FieldPanel
from events import types
from events.utils import get_event_datetime_display_string

Expand Down
4 changes: 1 addition & 3 deletions src/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.admin.panels import (
FieldPanel,
InlinePanel,
MultiFieldPanel,
)
from wagtail.models import PagePermissionTester
Expand All @@ -23,7 +21,7 @@
from content.models import BasePage, ContentPage
from core.models import fields
from core.models.models import SiteAlertBanner
from core.panels import PageSelectorPanel
from core.panels import FieldPanel, InlinePanel, PageSelectorPanel
from events.models import EventPage
from home.forms import HomePageForm
from home.validators import validate_home_priority_pages
Expand Down
2 changes: 1 addition & 1 deletion src/networks/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django import forms
from wagtail.admin.forms import WagtailAdminPageForm
from wagtail.admin.panels import FieldPanel

import peoplefinder.models as pf_models
from content.models import ContentOwnerMixin, ContentPage
from core.panels import FieldPanel
from extended_search.index import DWIndexedField as IndexedField


Expand Down
2 changes: 1 addition & 1 deletion src/news/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from django.utils.text import slugify
from modelcluster.fields import ParentalKey
from simple_history.models import HistoricalRecords
from wagtail.admin.panels import FieldPanel, InlinePanel
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.snippets.models import register_snippet

from content.models import BasePage
from core.panels import FieldPanel, InlinePanel
from extended_search.index import DWIndexedField as IndexedField
from extended_search.index import ScoreFunction
from news.forms import CommentForm
Expand Down
Loading

0 comments on commit 8055239

Please sign in to comment.