feat: Add djangocms-rest support - #378
Conversation
Reviewer's GuideAdds optional integration with djangocms-rest, exposing alias placeholders via a headless API endpoint, wiring the Alias plugin to an inline serializer, and providing end-to-end REST tests guarded by conditional imports so behavior is unchanged when djangocms-rest is absent. Sequence diagram for djangocms-rest alias placeholder API endpointsequenceDiagram
actor Client
participant Router as DjangoRouter
participant View as AliasContentView
participant AliasModel as Alias
participant PlaceholderSerializer
participant DRFResponse as Response
Client->>Router: GET /<language>/aliases/<pk>/
Router->>View: dispatch get(language, pk)
View->>AliasModel: objects.filter(pk=pk).first()
AliasModel-->>View: alias or None
alt alias is None
View->>View: raise NotFound
else alias exists
View->>AliasModel: get_placeholder(language, show_draft_content)
AliasModel-->>View: placeholder or None
alt placeholder is None
View->>View: raise NotFound
else placeholder exists
View->>PlaceholderSerializer: __init__(instance=placeholder, request=request, language=language)
View->>PlaceholderSerializer: data
PlaceholderSerializer-->>View: serialized_placeholder
View->>DRFResponse: __init__(serialized_placeholder)
DRFResponse-->>Client: 200 OK
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Co-authored-by: Marc Widmer <marc@pbi.io>
1ef1d1e to
d2685a0
Compare
|
@fsbraun : I implemented the PR in my test setup. The plugin serialization works as expected. What i do not get is how we serialize a static alias, for example footer. I add one to my base template and either would expect serialization directly in pages or via endpoint and identifier "footer". Currently i can serialize it via id:
I would i expect to use the natural language identifiert "footer" similar to use in template: What is your take on this issue? Do i miss something? |
for more information, see https://pre-commit.ci
# Conflicts: # djangocms_alias/models.py # tests/requirements/py312-dj52-cms51-default.txt # tests/requirements/py312-dj52-cms51-versioning.txt # tests/requirements/py313-dj52-cms50-default.txt # tests/requirements/py313-dj52-cms50-versioning.txt # tests/requirements/py313-dj60-cms50-default.txt # tests/requirements/py313-dj60-cms50-versioning.txt # tests/requirements/py314-dj52-cms50-default.txt # tests/requirements/py314-dj52-cms50-versioning.txt # tests/requirements/py314-dj60-cms50-default.txt # tests/requirements/py314-dj60-cms50-versioning.txt # tests/requirements/py314-dj61-cms50-default.txt # tests/requirements/py314-dj61-cms50-versioning.txt
`HAS_REST` was hard-coded to `False`, so all 25 tests in the REST integration suite skipped unconditionally. The comment next to it deferred activation until djangocms-rest supported the cms_config hook; that landed on djangocms-rest main in "feat: Allow django cms apps to register for rest support" (#115), which is what `tests/requirements/requirements.in` already tracks. Probe for the package instead, mirroring `tests/settings.py`, which only adds `djangocms_rest` and its dependencies to `INSTALLED_APPS` when it is importable. Environments without it keep skipping. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GwNaBKq7MNLhibbjjiAYHM
The djangocms-rest integration shipped without any mention in the README: the two alias endpoints, addressing static aliases by their static code, the ?preview=true draft access and its permission, and the inline expansion of Alias plugins in page responses were all undocumented. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GwNaBKq7MNLhibbjjiAYHM
Summary by Sourcery
Integrate optional djangocms-rest support to expose alias content via the headless API and ensure Alias plugins serialize correctly through REST endpoints.
New Features:
Enhancements:
Tests:
Related resources
Checklist
Summary by Sourcery
Integrate optional djangocms-rest support to expose alias content and serialize nested Alias plugins through the headless API.
New Features:
Enhancements:
Build:
Documentation:
Tests: