Conversation
jrdh
force-pushed
the
fix/cdd-3498-resolve-page-classification-clashes
branch
from
August 3, 2026 23:00
dce32d6 to
7f47de7
Compare
9 tasks
jrdh
force-pushed
the
fix/cdd-3498-resolve-page-classification-clashes
branch
from
August 4, 2026 07:46
fc6a36e to
b9d10df
Compare
itsthatianguy
previously approved these changes
Aug 7, 2026
jrdh
force-pushed
the
fix/cdd-3498-resolve-page-classification-clashes
branch
from
August 7, 2026 10:06
fb557ce to
00ba02b
Compare
Topic and metric documnetation child pages are non-public capable pages which therefore must have the non-public tick box, page classification, theme, sub-theme, topic, and metric associated with them to allow us to filter based on a user's permissions if the page is set to non-public. In the original implementation of this, there was a bug where the metric field on the documentation child page model was being reused as it already existed. Conceptually this is incorrect as it should have been a separate field, but also it broke the metric child pages as they were expecting the metric to be stored as the full name of the metric whereas the non-public logic was expecting an ID. To solve this, the metric field has been removed because it's not currently in scope for page permissions. However, to future proof this and also reduce repeated code (the topic and metric documentation child models have the same code copied in both) a new non-public abstract page model has been created which carries the core fields required for a non-public page. The topic and metric documentation child page models are no subclasses of this page. As mentioned, the metric field for non-pub page permissions has been removed rather than left half implemented. Additionally, the theme, sub-theme, and topic fields have been renamed with the prefix `page_` to avoid clashing with possible fields on subclasses. This aligns with the `page_classification` that already existed. On top of this, the admin form for non-public fields has been centralised into a class as well to again avoid copied code. This presents the fields slightly differently to try and make the DPD editor user experience better - the public checkbox still shows as before but the classification, theme, sub-theme, and topic are grouped together and collapsed by default to reduce clutter when they are likely only to be set once and not looked at again. These could be moved into a tab potentially if we wanted to but for the moment this change is better than before and makes it clearer for users. There is also a performance fix within this commit which I tried to split out but it didn't work as it's related to the changes described above. Specifically, the populating of choices on the metric documentation child model is moved from the `__init__` method to the editor's `__init__`. This means we don't pull metric names from the db on every instantiation of a new metric documentation object (which for example could happen 80+ times (depends how many metric documentation child pages you have) just through the get pages endpoint (because we use `.specific()`). Finally, to facilitate the field changes on the topic and metric documentation child pages, migrations have been created. These are written as renames to try and avoid data loss. However, any metric documentation child pages which were created with the old code will need to fixed as their database entries will be incorrect (they'll be using an ID in the `metric` column instead of a string name). This has been fixed in the bootstrap code as well as the issue was present there too.
If this class is inheritied from that doesn't mean the page is NonPublic, it means it can be, so this is a better name.
…ild page unit test
jrdh
force-pushed
the
fix/cdd-3498-resolve-page-classification-clashes
branch
from
August 11, 2026 21:31
00ba02b to
3534333
Compare
itsthatianguy
approved these changes
Aug 27, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Topic and metric documentation child pages are non-public capable pages which therefore must have the non-public tick box, page classification, theme, sub-theme, topic, and metric associated with them to allow us to filter based on a user's permissions if the page is set to non-public.
In the original implementation of this, there was a bug where the metric field on the documentation child page model was being reused as it already existed. Conceptually this is incorrect as it should have been a separate field, but this approach also broke the metric child pages as they were expecting the metric to be stored as the full name of the metric whereas the non-public logic was expecting an ID. To solve this, the metric field has been removed because it's not currently in scope for page permissions and was only half implemented anyway.
To future proof non-public pages and also reduce repeated code (the topic and metric documentation child models have the same code copied in both) a new non-public abstract page model has been created which carries the core fields required for a non-public page. The topic and metric documentation child page models are now subclasses of this page.
Additionally, the theme, sub-theme, and topic fields have been renamed with the prefix
page_to avoid clashing with possible fields on subclasses. This aligns with thepage_classificationthat already existed.On top of this, the admin form for non-public fields has been centralised into a class as well to again avoid copied code. This presents the fields slightly differently to try and make the DPD editor user experience better - the public checkbox still shows as before but the classification, theme, sub-theme, and topic are grouped together and collapsed by
default to reduce clutter when they are likely only to be set once and not looked at again. These could be moved into a tab potentially if we wanted to but for the moment this change is better than before and makes it clearer for users.
This means this:

Now looks like this:

There is also a performance fix within this PR which I tried to split out but couldn't as it's related to the changes described above. Specifically, the populating of choices on the metric documentation child model is moved from the
__init__method to the admin form's__init__. This means we don't pull metric names from the db on every instantiation of a new metric documentation object (which for example could happen 80+ times (depends how manymetric documentation child pages you have) just through the get pages endpoint (because we use
.specific()).Finally, to facilitate the field changes on the topic and metric documentation child pages, migrations have been created. These are written as renames to try and avoid data loss. However, any metric documentation child pages which were created with the old code will need to fixed as their database entries will be incorrect (they'll be using an ID in the
metriccolumn instead of a string name). This has been fixed in the bootstrap code as well as the issue was present there too.Fixes #CDD-3498
Type of change
Please select the options that are relevant.
Checklist: