From 2660a80f0a18acbc3da7821da7bbf6f958468472 Mon Sep 17 00:00:00 2001 From: Cameron Lamb Date: Tue, 8 Oct 2024 14:07:24 +0100 Subject: [PATCH 1/5] Component fixups (#770) --- src/dw_design_system/dwds/components/engagement.html | 2 +- src/dw_design_system/dwds/layouts/content_grid.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dw_design_system/dwds/components/engagement.html b/src/dw_design_system/dwds/components/engagement.html index aaa8ab1b7..551adad52 100644 --- a/src/dw_design_system/dwds/components/engagement.html +++ b/src/dw_design_system/dwds/components/engagement.html @@ -1,6 +1,6 @@ {% load wagtailimages_tags static humanize %} -
+
{% include "dwds/elements/content_image.html" with content_image=thumbnail %} diff --git a/src/dw_design_system/dwds/layouts/content_grid.scss b/src/dw_design_system/dwds/layouts/content_grid.scss index 54f1f24b0..bc941510e 100644 --- a/src/dw_design_system/dwds/layouts/content_grid.scss +++ b/src/dw_design_system/dwds/layouts/content_grid.scss @@ -1,6 +1,10 @@ .content-grid { display: grid; grid-gap: var(--space); + + .content-item { + display: flex; + } } .content-grid.image-left, From 223681d0f1c4afcd448f10011e855620d14c59ea Mon Sep 17 00:00:00 2001 From: Cameron Lamb Date: Tue, 8 Oct 2024 15:10:32 +0100 Subject: [PATCH 2/5] Fix the engagement streamfield content (#771) --- .../dwds/components/engagement_card.py | 2 +- src/home/templatetags/cards.py | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/dw_design_system/dwds/components/engagement_card.py b/src/dw_design_system/dwds/components/engagement_card.py index 890c5587f..ed49c3776 100644 --- a/src/dw_design_system/dwds/components/engagement_card.py +++ b/src/dw_design_system/dwds/components/engagement_card.py @@ -5,7 +5,7 @@ class EngagementCardBlock(blocks.StructBlock): page = blocks.PageChooserBlock(page_type="content.ContentPage") class Meta: - template = "dwds/components/engagement_card.html" + template = "dwds/components/engagement.html" icon = "doc-empty" label = "Engagement Card" diff --git a/src/home/templatetags/cards.py b/src/home/templatetags/cards.py index ddcba69f2..fb7c28a0a 100644 --- a/src/home/templatetags/cards.py +++ b/src/home/templatetags/cards.py @@ -38,19 +38,6 @@ def page_to_display_context(page: NewsPage | EventPage): return context -@register.simple_tag -def page_to_card(page: NewsPage | EventPage, hide_shadow: bool = False): - return { - **page_to_display_context(page), - "template": "dwds/components/engagement_card.html", - } - - -@register.simple_tag -def pages_to_cards(pages: list[NewsPage | EventPage], hide_shadow: bool = False): - return [page_to_card(page, hide_shadow=hide_shadow) for page in pages] - - class RenderableComponent: def __init__(self, template_name: str, context: dict): self.template_name = template_name From 8cde860bcc7222d160b17753840b9d60a0ee63d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:37:28 +0100 Subject: [PATCH 3/5] Bump @sentry/browser from 6.19.7 to 7.119.1 (#768) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Cameron Lamb --- assets/js/init.js | 3 +- package-lock.json | 280 ++++++++++++++++++++++++++++++++++++---------- package.json | 3 +- 3 files changed, 220 insertions(+), 66 deletions(-) diff --git a/assets/js/init.js b/assets/js/init.js index 31edba769..5ece16462 100644 --- a/assets/js/init.js +++ b/assets/js/init.js @@ -1,5 +1,4 @@ import * as Sentry from "@sentry/browser"; -import { BrowserTracing } from "@sentry/tracing"; /** * Return config from meta html elements. @@ -24,7 +23,7 @@ function sentryInit() { dsn, release: config("release"), environment: config("environment"), - integrations: [new BrowserTracing()], + integrations: [Sentry.browserTracingIntegration()], tracesSampleRate: Number(config("sentry:browser-traces-sample-rate")), }); } diff --git a/package-lock.json b/package-lock.json index 6027bcdf5..f6fc0894b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,7 @@ "version": "0.1.0", "dependencies": { "@ministryofjustice/frontend": "^1.8.0", - "@sentry/browser": "^6.19.7", - "@sentry/tracing": "^6.19.7", + "@sentry/browser": "^7.119.1", "cropperjs": "^1.5.13", "css-loader": "^5.2.7", "govuk-frontend": "^4.5.0", @@ -106,94 +105,235 @@ "jquery": "^3.6.0" } }, + "node_modules/@sentry-internal/feedback": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-7.119.1.tgz", + "integrity": "sha512-EPyW6EKZmhKpw/OQUPRkTynXecZdYl4uhZwdZuGqnGMAzswPOgQvFrkwsOuPYvoMfXqCH7YuRqyJrox3uBOrTA==", + "dependencies": { + "@sentry/core": "7.119.1", + "@sentry/types": "7.119.1", + "@sentry/utils": "7.119.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry-internal/feedback/node_modules/@sentry/types": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.119.1.tgz", + "integrity": "sha512-4G2mcZNnYzK3pa2PuTq+M2GcwBRY/yy1rF+HfZU+LAPZr98nzq2X3+mJHNJoobeHRkvVh7YZMPi4ogXiIS5VNQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/feedback/node_modules/@sentry/utils": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.119.1.tgz", + "integrity": "sha512-ju/Cvyeu/vkfC5/XBV30UNet5kLEicZmXSyuLwZu95hEbL+foPdxN+re7pCI/eNqfe3B2vz7lvz5afLVOlQ2Hg==", + "dependencies": { + "@sentry/types": "7.119.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/replay-canvas": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-7.119.1.tgz", + "integrity": "sha512-O/lrzENbMhP/UDr7LwmfOWTjD9PLNmdaCF408Wx8SDuj7Iwc+VasGfHg7fPH4Pdr4nJON6oh+UqoV4IoG05u+A==", + "dependencies": { + "@sentry/core": "7.119.1", + "@sentry/replay": "7.119.1", + "@sentry/types": "7.119.1", + "@sentry/utils": "7.119.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry-internal/replay-canvas/node_modules/@sentry/types": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.119.1.tgz", + "integrity": "sha512-4G2mcZNnYzK3pa2PuTq+M2GcwBRY/yy1rF+HfZU+LAPZr98nzq2X3+mJHNJoobeHRkvVh7YZMPi4ogXiIS5VNQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/replay-canvas/node_modules/@sentry/utils": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.119.1.tgz", + "integrity": "sha512-ju/Cvyeu/vkfC5/XBV30UNet5kLEicZmXSyuLwZu95hEbL+foPdxN+re7pCI/eNqfe3B2vz7lvz5afLVOlQ2Hg==", + "dependencies": { + "@sentry/types": "7.119.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/tracing": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.119.1.tgz", + "integrity": "sha512-cI0YraPd6qBwvUA3wQdPGTy8PzAoK0NZiaTN1LM3IczdPegehWOaEG5GVTnpGnTsmBAzn1xnBXNBhgiU4dgcrQ==", + "dependencies": { + "@sentry/core": "7.119.1", + "@sentry/types": "7.119.1", + "@sentry/utils": "7.119.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/tracing/node_modules/@sentry/types": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.119.1.tgz", + "integrity": "sha512-4G2mcZNnYzK3pa2PuTq+M2GcwBRY/yy1rF+HfZU+LAPZr98nzq2X3+mJHNJoobeHRkvVh7YZMPi4ogXiIS5VNQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry-internal/tracing/node_modules/@sentry/utils": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.119.1.tgz", + "integrity": "sha512-ju/Cvyeu/vkfC5/XBV30UNet5kLEicZmXSyuLwZu95hEbL+foPdxN+re7pCI/eNqfe3B2vz7lvz5afLVOlQ2Hg==", + "dependencies": { + "@sentry/types": "7.119.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sentry/browser": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.19.7.tgz", - "integrity": "sha512-oDbklp4O3MtAM4mtuwyZLrgO1qDVYIujzNJQzXmi9YzymJCuzMLSRDvhY83NNDCRxf0pds4DShgYeZdbSyKraA==", + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.119.1.tgz", + "integrity": "sha512-aMwAnFU4iAPeLyZvqmOQaEDHt/Dkf8rpgYeJ0OEi50dmP6AjG+KIAMCXU7CYCCQDn70ITJo8QD5+KzCoZPYz0A==", "dependencies": { - "@sentry/core": "6.19.7", - "@sentry/types": "6.19.7", - "@sentry/utils": "6.19.7", - "tslib": "^1.9.3" + "@sentry-internal/feedback": "7.119.1", + "@sentry-internal/replay-canvas": "7.119.1", + "@sentry-internal/tracing": "7.119.1", + "@sentry/core": "7.119.1", + "@sentry/integrations": "7.119.1", + "@sentry/replay": "7.119.1", + "@sentry/types": "7.119.1", + "@sentry/utils": "7.119.1" }, "engines": { - "node": ">=6" + "node": ">=8" + } + }, + "node_modules/@sentry/browser/node_modules/@sentry/types": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.119.1.tgz", + "integrity": "sha512-4G2mcZNnYzK3pa2PuTq+M2GcwBRY/yy1rF+HfZU+LAPZr98nzq2X3+mJHNJoobeHRkvVh7YZMPi4ogXiIS5VNQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser/node_modules/@sentry/utils": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.119.1.tgz", + "integrity": "sha512-ju/Cvyeu/vkfC5/XBV30UNet5kLEicZmXSyuLwZu95hEbL+foPdxN+re7pCI/eNqfe3B2vz7lvz5afLVOlQ2Hg==", + "dependencies": { + "@sentry/types": "7.119.1" + }, + "engines": { + "node": ">=8" } }, "node_modules/@sentry/core": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-6.19.7.tgz", - "integrity": "sha512-tOfZ/umqB2AcHPGbIrsFLcvApdTm9ggpi/kQZFkej7kMphjT+SGBiQfYtjyg9jcRW+ilAR4JXC9BGKsdEQ+8Vw==", + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.119.1.tgz", + "integrity": "sha512-YUNnH7O7paVd+UmpArWCPH4Phlb5LwrkWVqzFWqL3xPyCcTSof2RL8UmvpkTjgYJjJ+NDfq5mPFkqv3aOEn5Sw==", "dependencies": { - "@sentry/hub": "6.19.7", - "@sentry/minimal": "6.19.7", - "@sentry/types": "6.19.7", - "@sentry/utils": "6.19.7", - "tslib": "^1.9.3" + "@sentry/types": "7.119.1", + "@sentry/utils": "7.119.1" }, "engines": { - "node": ">=6" + "node": ">=8" + } + }, + "node_modules/@sentry/core/node_modules/@sentry/types": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.119.1.tgz", + "integrity": "sha512-4G2mcZNnYzK3pa2PuTq+M2GcwBRY/yy1rF+HfZU+LAPZr98nzq2X3+mJHNJoobeHRkvVh7YZMPi4ogXiIS5VNQ==", + "engines": { + "node": ">=8" } }, - "node_modules/@sentry/hub": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.19.7.tgz", - "integrity": "sha512-y3OtbYFAqKHCWezF0EGGr5lcyI2KbaXW2Ik7Xp8Mu9TxbSTuwTe4rTntwg8ngPjUQU3SUHzgjqVB8qjiGqFXCA==", + "node_modules/@sentry/core/node_modules/@sentry/utils": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.119.1.tgz", + "integrity": "sha512-ju/Cvyeu/vkfC5/XBV30UNet5kLEicZmXSyuLwZu95hEbL+foPdxN+re7pCI/eNqfe3B2vz7lvz5afLVOlQ2Hg==", "dependencies": { - "@sentry/types": "6.19.7", - "@sentry/utils": "6.19.7", - "tslib": "^1.9.3" + "@sentry/types": "7.119.1" }, "engines": { - "node": ">=6" + "node": ">=8" } }, - "node_modules/@sentry/minimal": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.19.7.tgz", - "integrity": "sha512-wcYmSJOdvk6VAPx8IcmZgN08XTXRwRtB1aOLZm+MVHjIZIhHoBGZJYTVQS/BWjldsamj2cX3YGbGXNunaCfYJQ==", + "node_modules/@sentry/integrations": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-7.119.1.tgz", + "integrity": "sha512-CGmLEPnaBqbUleVqrmGYjRjf5/OwjUXo57I9t0KKWViq81mWnYhaUhRZWFNoCNQHns+3+GPCOMvl0zlawt+evw==", "dependencies": { - "@sentry/hub": "6.19.7", - "@sentry/types": "6.19.7", - "tslib": "^1.9.3" + "@sentry/core": "7.119.1", + "@sentry/types": "7.119.1", + "@sentry/utils": "7.119.1", + "localforage": "^1.8.1" }, "engines": { - "node": ">=6" + "node": ">=8" + } + }, + "node_modules/@sentry/integrations/node_modules/@sentry/types": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.119.1.tgz", + "integrity": "sha512-4G2mcZNnYzK3pa2PuTq+M2GcwBRY/yy1rF+HfZU+LAPZr98nzq2X3+mJHNJoobeHRkvVh7YZMPi4ogXiIS5VNQ==", + "engines": { + "node": ">=8" } }, - "node_modules/@sentry/tracing": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.19.7.tgz", - "integrity": "sha512-ol4TupNnv9Zd+bZei7B6Ygnr9N3Gp1PUrNI761QSlHtPC25xXC5ssSD3GMhBgyQrcvpuRcCFHVNNM97tN5cZiA==", + "node_modules/@sentry/integrations/node_modules/@sentry/utils": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.119.1.tgz", + "integrity": "sha512-ju/Cvyeu/vkfC5/XBV30UNet5kLEicZmXSyuLwZu95hEbL+foPdxN+re7pCI/eNqfe3B2vz7lvz5afLVOlQ2Hg==", "dependencies": { - "@sentry/hub": "6.19.7", - "@sentry/minimal": "6.19.7", - "@sentry/types": "6.19.7", - "@sentry/utils": "6.19.7", - "tslib": "^1.9.3" + "@sentry/types": "7.119.1" }, "engines": { - "node": ">=6" + "node": ">=8" + } + }, + "node_modules/@sentry/replay": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.119.1.tgz", + "integrity": "sha512-4da+ruMEipuAZf35Ybt2StBdV1S+oJbSVccGpnl9w6RoeQoloT4ztR6ML3UcFDTXeTPT1FnHWDCyOfST0O7XMw==", + "dependencies": { + "@sentry-internal/tracing": "7.119.1", + "@sentry/core": "7.119.1", + "@sentry/types": "7.119.1", + "@sentry/utils": "7.119.1" + }, + "engines": { + "node": ">=12" } }, - "node_modules/@sentry/types": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.19.7.tgz", - "integrity": "sha512-jH84pDYE+hHIbVnab3Hr+ZXr1v8QABfhx39KknxqKWr2l0oEItzepV0URvbEhB446lk/S/59230dlUUIBGsXbg==", + "node_modules/@sentry/replay/node_modules/@sentry/types": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.119.1.tgz", + "integrity": "sha512-4G2mcZNnYzK3pa2PuTq+M2GcwBRY/yy1rF+HfZU+LAPZr98nzq2X3+mJHNJoobeHRkvVh7YZMPi4ogXiIS5VNQ==", "engines": { - "node": ">=6" + "node": ">=8" } }, - "node_modules/@sentry/utils": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.19.7.tgz", - "integrity": "sha512-z95ECmE3i9pbWoXQrD/7PgkBAzJYR+iXtPuTkpBjDKs86O3mT+PXOT3BAn79w2wkn7/i3vOGD2xVr1uiMl26dA==", + "node_modules/@sentry/replay/node_modules/@sentry/utils": { + "version": "7.119.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.119.1.tgz", + "integrity": "sha512-ju/Cvyeu/vkfC5/XBV30UNet5kLEicZmXSyuLwZu95hEbL+foPdxN+re7pCI/eNqfe3B2vz7lvz5afLVOlQ2Hg==", "dependencies": { - "@sentry/types": "6.19.7", - "tslib": "^1.9.3" + "@sentry/types": "7.119.1" }, "engines": { - "node": ">=6" + "node": ">=8" } }, "node_modules/@types/estree": { @@ -864,6 +1004,11 @@ "postcss": "^8.1.0" } }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" + }, "node_modules/immutable": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz", @@ -1024,6 +1169,14 @@ "node": ">= 8" } }, + "node_modules/lie": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", + "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==", + "dependencies": { + "immediate": "~3.0.5" + } + }, "node_modules/loader-runner": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", @@ -1045,6 +1198,14 @@ "node": ">=8.9.0" } }, + "node_modules/localforage": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", + "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==", + "dependencies": { + "lie": "3.1.1" + } + }, "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -1728,11 +1889,6 @@ "node": ">=8.0" } }, - "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "node_modules/undici-types": { "version": "6.19.8", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", diff --git a/package.json b/package.json index 9c73d1e77..5a67f387e 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "private": true, "dependencies": { "@ministryofjustice/frontend": "^1.8.0", - "@sentry/browser": "^6.19.7", - "@sentry/tracing": "^6.19.7", + "@sentry/browser": "^7.119.1", "cropperjs": "^1.5.13", "css-loader": "^5.2.7", "govuk-frontend": "^4.5.0", From d6a701f5634611fbc866db3f502d511eebc3b89b Mon Sep 17 00:00:00 2001 From: David Okeke <140066072+david-okeke1337@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:37:39 +0100 Subject: [PATCH 4/5] INTR-342 Event page start/end dates (#766) Co-authored-by: Cameron Lamb --- .../dwds/components/engagement.html | 5 +- .../dwds/components/one_up.html | 5 +- ...0004_remove_eventpage_end_time_and_more.py | 95 +++++++++++++++++++ src/events/models.py | 24 ++--- src/events/templates/events/event_page.html | 4 +- src/events/templates/events/events_home.html | 2 +- src/events/utils.py | 22 +++-- src/home/models.py | 4 +- src/home/templatetags/cards.py | 9 +- 9 files changed, 133 insertions(+), 37 deletions(-) create mode 100644 src/events/migrations/0004_remove_eventpage_end_time_and_more.py diff --git a/src/dw_design_system/dwds/components/engagement.html b/src/dw_design_system/dwds/components/engagement.html index 551adad52..f75d5d9b5 100644 --- a/src/dw_design_system/dwds/components/engagement.html +++ b/src/dw_design_system/dwds/components/engagement.html @@ -12,10 +12,9 @@

{{ title }}

- {% if post_title_date and post_title_time %} + {% if post_title %}
-

{{ post_title_date }}

-

{{ post_title_time }}

+

{{ post_title }}

{% endif %} {% if excerpt %}

{{ excerpt|truncatewords:16 }}

{% endif %} diff --git a/src/dw_design_system/dwds/components/one_up.html b/src/dw_design_system/dwds/components/one_up.html index 7e5518afa..733d7267c 100644 --- a/src/dw_design_system/dwds/components/one_up.html +++ b/src/dw_design_system/dwds/components/one_up.html @@ -10,10 +10,9 @@

{{ title }}

- {% if post_title_date and post_title_time %} + {% if post_title %}
-

{{ post_title_date }}

-

{{ post_title_time }}

+

{{ post_title }}

{% endif %} {% if excerpt %}

{{ excerpt|truncatewords:16 }}

{% endif %} diff --git a/src/events/migrations/0004_remove_eventpage_end_time_and_more.py b/src/events/migrations/0004_remove_eventpage_end_time_and_more.py new file mode 100644 index 000000000..5e118363a --- /dev/null +++ b/src/events/migrations/0004_remove_eventpage_end_time_and_more.py @@ -0,0 +1,95 @@ +# Generated by Django 4.2.15 on 2024-10-02 12:42 + +import datetime +from django.db import migrations, models +from datetime import datetime as dt +import django.utils.timezone + + +def copy_events(apps, schema_editor): + EventPage = apps.get_model("events", "EventPage") + + for event_page in EventPage.objects.all(): + event_page.event_start = dt.combine( + event_page.event_date, event_page.start_time + ) + event_page.event_end = dt.combine(event_page.event_date, event_page.end_time) + event_page.save() + + +def reverse_copy_events(apps, schema_editor): + EventPage = apps.get_model("events", "EventPage") + + for event_page in EventPage.objects.all(): + event_page.event_date = event_page.event_start.date() + event_page.start_time = event_page.event_start.time() + event_page.end_time = event_page.event_end.time() + event_page.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("events", "0003_alter_eventpage_event_recording_url_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="eventpage", + name="event_start", + field=models.DateTimeField( + default=django.utils.timezone.now, + help_text="Start date/time of the event.", + ), + preserve_default=False, + ), + migrations.AddField( + model_name="eventpage", + name="event_end", + field=models.DateTimeField( + default=datetime.datetime( + 2024, 10, 2, 12, 42, 15, 793134, tzinfo=datetime.timezone.utc + ), + help_text="End date/time of the event.", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="eventpage", + name="event_date", + field=models.DateField( + help_text="Date and time should be entered based on the time in London/England.", + blank=True, + null=True, + ), + ), + migrations.AlterField( + model_name="eventpage", + name="start_time", + field=models.TimeField( + blank=True, + null=True, + ), + ), + migrations.AlterField( + model_name="eventpage", + name="end_time", + field=models.TimeField( + blank=True, + null=True, + ), + ), + migrations.RunPython(copy_events, reverse_code=reverse_copy_events), + migrations.RemoveField( + model_name="eventpage", + name="event_date", + ), + migrations.RemoveField( + model_name="eventpage", + name="start_time", + ), + migrations.RemoveField( + model_name="eventpage", + name="end_time", + ), + ] diff --git a/src/events/models.py b/src/events/models.py index 9fb7a352e..6c3880321 100644 --- a/src/events/models.py +++ b/src/events/models.py @@ -1,4 +1,3 @@ -from datetime import datetime as dt from datetime import timedelta from django.db import models @@ -8,7 +7,7 @@ from content.models import BasePage, ContentPage from core.models import fields from events import types -from events.utils import get_event_date, get_event_time +from events.utils import get_event_datetime_display_string class EventsHome(BasePage): @@ -33,11 +32,12 @@ class EventPage(ContentPage): parent_page_types = ["events.EventsHome"] template = "events/event_page.html" - event_date = models.DateField( - help_text="Date and time should be entered based on the time in London/England.", + event_start = models.DateTimeField( + help_text="Start date/time of the event.", + ) + event_end = models.DateTimeField( + help_text="End date/time of the event.", ) - start_time = models.TimeField() - end_time = models.TimeField() online_event_url = fields.URLField( blank=True, null=True, @@ -90,11 +90,10 @@ class EventPage(ContentPage): content_panels = ContentPage.content_panels + [ MultiFieldPanel( [ - FieldPanel("event_date"), FieldRowPanel( [ - FieldPanel("start_time"), - FieldPanel("end_time"), + FieldPanel("event_start"), + FieldPanel("event_end"), ] ), ], @@ -135,15 +134,12 @@ def get_context(self, request, *args, **kwargs): is_online=self.event_type == types.EventType.ONLINE, is_in_person=self.event_type == types.EventType.IN_PERSON, is_hybrid=self.event_type == types.EventType.HYBRID, - event_date=get_event_date(self), - event_time=get_event_time(self), + event_date_range=get_event_datetime_display_string(self), ) return context @property def is_past_event(self) -> bool: - adjusted_datetime = timezone.make_aware( - dt.combine(self.event_date, self.end_time) + timedelta(hours=1) - ) + adjusted_datetime = timezone.make_aware(self.event_end + timedelta(hours=1)) return timezone.now() > adjusted_datetime diff --git a/src/events/templates/events/event_page.html b/src/events/templates/events/event_page.html index 1a136a763..2a0ea196b 100644 --- a/src/events/templates/events/event_page.html +++ b/src/events/templates/events/event_page.html @@ -23,9 +23,7 @@
When
- {{ event_date }} -
- {{ event_time }} + {{ event_date_range }}
{% if is_in_person or is_hybrid %}
Location
diff --git a/src/events/templates/events/events_home.html b/src/events/templates/events/events_home.html index 9c37d77a9..707ed860d 100644 --- a/src/events/templates/events/events_home.html +++ b/src/events/templates/events/events_home.html @@ -16,7 +16,7 @@

{{ event.title }}

-

{{ event.event_date }}

+

{{ event.event_start|date:"d M Y" }}

{% image event.preview_image width-540 %}

{{ event.description }}

diff --git a/src/events/utils.py b/src/events/utils.py index 14c19e768..fc94017f7 100644 --- a/src/events/utils.py +++ b/src/events/utils.py @@ -1,5 +1,7 @@ from typing import TYPE_CHECKING +from django.utils.safestring import mark_safe + from core.utils import format_time @@ -7,11 +9,19 @@ from events.models import EventPage -def get_event_date(event: "EventPage") -> str: - return event.event_date.strftime("%-d %B %Y") +def get_event_datetime_display_string(event: "EventPage") -> str: + event_start_date = event.event_start.strftime("%-d %B %Y") + event_end_date = event.event_end.strftime("%-d %B %Y") + event_start_time = format_time(event.event_start.time()) + event_end_time = format_time(event.event_end.time()) + if event_start_date == event_end_date: + event_post_title = mark_safe( # noqa S308 + f"{event_start_date}
{event_start_time} - {event_end_time}" + ) + else: + event_post_title = mark_safe( # noqa S308 + f"{event_start_date} {event_start_time} -
{event_end_date} {event_end_time}" + ) -def get_event_time(event: "EventPage") -> str: - start_time = format_time(event.start_time) - end_time = format_time(event.end_time) - return f"{start_time} - {end_time}" + return event_post_title diff --git a/src/home/models.py b/src/home/models.py index f4f2c8184..41548d92e 100644 --- a/src/home/models.py +++ b/src/home/models.py @@ -313,9 +313,9 @@ def get_context(self, request, *args, **kwargs): events = ( EventPage.objects.live() .public() - .filter(event_date__gte=timezone.now().date()) + .filter(event_end__gte=timezone.now()) .exclude(id__in=priority_page_ids) - .order_by("event_date", "start_time") + .order_by("event_start") ) context.update( diff --git a/src/home/templatetags/cards.py b/src/home/templatetags/cards.py index fb7c28a0a..0e048c5ab 100644 --- a/src/home/templatetags/cards.py +++ b/src/home/templatetags/cards.py @@ -3,7 +3,9 @@ from django.utils.safestring import SafeString from events.models import EventPage -from events.utils import get_event_date, get_event_time +from events.utils import ( + get_event_datetime_display_string, +) from news.models import NewsPage @@ -30,10 +32,7 @@ def page_to_display_context(page: NewsPage | EventPage): ) if issubclass(type(page), EventPage): - context.update( - post_title_date=get_event_date(page), - post_title_time=get_event_time(page), - ) + context.update(post_title=get_event_datetime_display_string(page)) return context From b6181523e9b3d791bfe0a47d18828939f624a473 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:26:04 +0100 Subject: [PATCH 5/5] Bump django from 4.2.15 to 4.2.16 (#772) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 176957754..0da682ea2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -937,13 +937,13 @@ typing-extensions = ">=3.10.0.0" [[package]] name = "django" -version = "4.2.15" +version = "4.2.16" description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." optional = false python-versions = ">=3.8" files = [ - {file = "Django-4.2.15-py3-none-any.whl", hash = "sha256:61ee4a130efb8c451ef3467c67ca99fdce400fedd768634efc86a68c18d80d30"}, - {file = "Django-4.2.15.tar.gz", hash = "sha256:c77f926b81129493961e19c0e02188f8d07c112a1162df69bfab178ae447f94a"}, + {file = "Django-4.2.16-py3-none-any.whl", hash = "sha256:1ddc333a16fc139fd253035a1606bb24261951bbc3a6ca256717fa06cc41a898"}, + {file = "Django-4.2.16.tar.gz", hash = "sha256:6f1616c2786c408ce86ab7e10f792b8f15742f7b7b7460243929cb371e7f1dad"}, ] [package.dependencies]