Skip to content

Commit e8ad06b

Browse files
authored
Merge pull request #3032 from UKHSA-Internal/task/CDD-3158-page-classification
CDD-3158: Add data classification to non public pages in the cms
2 parents d27bae5 + 0e17467 commit e8ad06b

File tree

16 files changed

+3336
-2876
lines changed

16 files changed

+3336
-2876
lines changed

cms/dashboard/management/commands/build_cms_site_helpers/pages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def create_topic_page(*, name: str, parent_page: Page) -> TopicPage:
133133
slug=data["meta"]["slug"],
134134
seo_title=data["meta"]["seo_title"],
135135
search_description=data["meta"]["search_description"],
136+
is_public=data["is_public"],
137+
page_classification=data["page_classification"]
136138
)
137139
_add_page_to_parent(page=page, parent_page=parent_page)
138140

cms/dashboard/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
BULLET_POINTS: str = "ul"
2121
LINKS: str = "link"
2222

23+
2324
AVAILABLE_RICH_TEXT_FEATURES: list[str] = [
2425
HEADING_2,
2526
HEADING_3,
@@ -32,6 +33,14 @@
3233
MAXIMUM_URL_FIELD_LENGTH: int = 400
3334

3435

36+
class DataClassificationLevels(models.TextChoices):
37+
OFFICIAL = "official"
38+
OFFICIAL_SENSITIVE = "official_sensitive"
39+
PROTECTIVE_MARKING_NOT_SET = "protective_marking_not_set"
40+
SECRET = "secret" # nosec #noqa: S105
41+
TOP_SECRET = "top_secret" # nosec #noqa: S105
42+
43+
3544
class UKHSAPage(Page):
3645
"""Abstract base class for all page types
3746
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
;(function () {
2+
function toggleClassification() {
3+
/*
4+
When the is_public box is checked, this will clear any selected page_classification,
5+
and disable the field. If the is_public box is then unchecked, it will re-enable the field
6+
*/
7+
const isPublicCheckbox = document.querySelector('input[name="is_public"]')
8+
const classificationField = document.querySelector(
9+
'select[name="page_classification"]',
10+
)
11+
12+
if (!isPublicCheckbox || !classificationField) return
13+
14+
if (isPublicCheckbox.checked) {
15+
classificationField.value = ""
16+
classificationField.disabled = true
17+
} else {
18+
classificationField.disabled = false
19+
}
20+
}
21+
22+
document.addEventListener("DOMContentLoaded", toggleClassification)
23+
document.addEventListener("change", function (e) {
24+
if (e.target.name === "is_public") {
25+
toggleClassification()
26+
}
27+
})
28+
})()

0 commit comments

Comments
 (0)