stapel-cms 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stapel_cms-0.1.0/CONFIG.MD +48 -0
- stapel_cms-0.1.0/LICENSE +21 -0
- stapel_cms-0.1.0/PKG-INFO +163 -0
- stapel_cms-0.1.0/README.md +125 -0
- stapel_cms-0.1.0/__init__.py +31 -0
- stapel_cms-0.1.0/_capabilities.py +32 -0
- stapel_cms-0.1.0/_codegen.py +123 -0
- stapel_cms-0.1.0/_codegen_settings.py +116 -0
- stapel_cms-0.1.0/actions.py +54 -0
- stapel_cms-0.1.0/admin.py +91 -0
- stapel_cms-0.1.0/apps.py +27 -0
- stapel_cms-0.1.0/beat.py +41 -0
- stapel_cms-0.1.0/blocks.py +363 -0
- stapel_cms-0.1.0/checks.py +120 -0
- stapel_cms-0.1.0/codegen_urls.py +6 -0
- stapel_cms-0.1.0/conf.py +92 -0
- stapel_cms-0.1.0/conftest.py +106 -0
- stapel_cms-0.1.0/docs/capabilities.json +212 -0
- stapel_cms-0.1.0/docs/errors.json +632 -0
- stapel_cms-0.1.0/docs/flows.json +611 -0
- stapel_cms-0.1.0/docs/llms.txt +194 -0
- stapel_cms-0.1.0/dto.py +195 -0
- stapel_cms-0.1.0/errors.py +76 -0
- stapel_cms-0.1.0/flows.py +51 -0
- stapel_cms-0.1.0/fsm.py +28 -0
- stapel_cms-0.1.0/functions.py +50 -0
- stapel_cms-0.1.0/gdpr.py +61 -0
- stapel_cms-0.1.0/management/__init__.py +0 -0
- stapel_cms-0.1.0/management/commands/__init__.py +0 -0
- stapel_cms-0.1.0/management/commands/cms_publish_due.py +12 -0
- stapel_cms-0.1.0/management/commands/cms_seed.py +25 -0
- stapel_cms-0.1.0/migrations/0001_initial.py +211 -0
- stapel_cms-0.1.0/migrations/__init__.py +0 -0
- stapel_cms-0.1.0/models.py +241 -0
- stapel_cms-0.1.0/pagination.py +113 -0
- stapel_cms-0.1.0/presenters.py +128 -0
- stapel_cms-0.1.0/py.typed +0 -0
- stapel_cms-0.1.0/pyproject.toml +96 -0
- stapel_cms-0.1.0/richtext.py +260 -0
- stapel_cms-0.1.0/safety.py +65 -0
- stapel_cms-0.1.0/schemas/consumes/user.merged.json +19 -0
- stapel_cms-0.1.0/schemas/emits/cms.menu.changed.json +30 -0
- stapel_cms-0.1.0/schemas/emits/cms.page.published.json +51 -0
- stapel_cms-0.1.0/schemas/emits/cms.page.unpublished.json +30 -0
- stapel_cms-0.1.0/schemas/emits/cms.post.published.json +60 -0
- stapel_cms-0.1.0/schemas/emits/cms.post.unpublished.json +30 -0
- stapel_cms-0.1.0/schemas/emits/cms.redirect.created.json +39 -0
- stapel_cms-0.1.0/schemas/functions/cms.feed.json +28 -0
- stapel_cms-0.1.0/schemas/functions/cms.resolve_path.json +27 -0
- stapel_cms-0.1.0/schemas/functions/cms.sitemap_entries.json +36 -0
- stapel_cms-0.1.0/schemas/functions/machine_translate.json +48 -0
- stapel_cms-0.1.0/serializers.py +470 -0
- stapel_cms-0.1.0/services/__init__.py +20 -0
- stapel_cms-0.1.0/services/cache.py +74 -0
- stapel_cms-0.1.0/services/content.py +436 -0
- stapel_cms-0.1.0/services/enrich.py +109 -0
- stapel_cms-0.1.0/services/events.py +59 -0
- stapel_cms-0.1.0/services/feed.py +43 -0
- stapel_cms-0.1.0/services/forms.py +114 -0
- stapel_cms-0.1.0/services/media.py +65 -0
- stapel_cms-0.1.0/services/menus.py +173 -0
- stapel_cms-0.1.0/services/paths.py +162 -0
- stapel_cms-0.1.0/services/preview.py +42 -0
- stapel_cms-0.1.0/services/public.py +299 -0
- stapel_cms-0.1.0/services/redirects.py +38 -0
- stapel_cms-0.1.0/services/seed.py +65 -0
- stapel_cms-0.1.0/services/sitemaps.py +54 -0
- stapel_cms-0.1.0/services/tags.py +53 -0
- stapel_cms-0.1.0/services/translate.py +175 -0
- stapel_cms-0.1.0/setup.cfg +4 -0
- stapel_cms-0.1.0/sitekeys.py +62 -0
- stapel_cms-0.1.0/stapel_cms.egg-info/PKG-INFO +163 -0
- stapel_cms-0.1.0/stapel_cms.egg-info/SOURCES.txt +175 -0
- stapel_cms-0.1.0/stapel_cms.egg-info/dependency_links.txt +1 -0
- stapel_cms-0.1.0/stapel_cms.egg-info/requires.txt +13 -0
- stapel_cms-0.1.0/stapel_cms.egg-info/top_level.txt +1 -0
- stapel_cms-0.1.0/tests/test_architecture.py +43 -0
- stapel_cms-0.1.0/tests/test_blocks.py +87 -0
- stapel_cms-0.1.0/tests/test_checks.py +46 -0
- stapel_cms-0.1.0/tests/test_concurrency.py +84 -0
- stapel_cms-0.1.0/tests/test_contract.py +148 -0
- stapel_cms-0.1.0/tests/test_contract_profile2.py +84 -0
- stapel_cms-0.1.0/tests/test_contract_wire.py +313 -0
- stapel_cms-0.1.0/tests/test_embed_hosts.py +27 -0
- stapel_cms-0.1.0/tests/test_error_i18n.py +228 -0
- stapel_cms-0.1.0/tests/test_forms_seam.py +107 -0
- stapel_cms-0.1.0/tests/test_functions.py +41 -0
- stapel_cms-0.1.0/tests/test_gdpr.py +54 -0
- stapel_cms-0.1.0/tests/test_media.py +40 -0
- stapel_cms-0.1.0/tests/test_media_enrich.py +96 -0
- stapel_cms-0.1.0/tests/test_migrations.py +17 -0
- stapel_cms-0.1.0/tests/test_pages.py +206 -0
- stapel_cms-0.1.0/tests/test_public.py +209 -0
- stapel_cms-0.1.0/tests/test_public_api.py +46 -0
- stapel_cms-0.1.0/tests/test_safety.py +171 -0
- stapel_cms-0.1.0/tests/test_seed_and_beat.py +46 -0
- stapel_cms-0.1.0/tests/test_sitemap.py +172 -0
- stapel_cms-0.1.0/tests/test_staff_site.py +104 -0
- stapel_cms-0.1.0/tests/test_translate_seam.py +230 -0
- stapel_cms-0.1.0/tests/test_variants.py +82 -0
- stapel_cms-0.1.0/tests/test_workflow.py +166 -0
- stapel_cms-0.1.0/translations/errors.es.json +30 -0
- stapel_cms-0.1.0/translations/errors.ru.json +30 -0
- stapel_cms-0.1.0/urls.py +13 -0
- stapel_cms-0.1.0/urls_v1.py +70 -0
- stapel_cms-0.1.0/views.py +793 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# CONFIG.MD — stapel-cms
|
|
2
|
+
|
|
3
|
+
Config registry for **stapel-cms**. One row per configuration key the module
|
|
4
|
+
reads, its **source** (`env` = the process environment / the `STAPEL_CMS`
|
|
5
|
+
settings dict), what it is for, whether it is required, and its default.
|
|
6
|
+
|
|
7
|
+
Every key is read through `cms_settings` (`stapel_cms.conf`, namespace
|
|
8
|
+
`STAPEL_CMS`). Resolution order per key: `settings.STAPEL_CMS` dict → a flat
|
|
9
|
+
Django setting of the same name → environment variable → the default below.
|
|
10
|
+
`BLOG_ENABLED` and `STAFF_AUTHZ` are CTO-facing config axes. `BLOCK_TYPES`
|
|
11
|
+
MERGES over the built-in block types; every other key replaces its default.
|
|
12
|
+
|
|
13
|
+
## stapel-cms
|
|
14
|
+
|
|
15
|
+
| Key | Source | Purpose | Required | Default |
|
|
16
|
+
|-----|--------|---------|----------|---------|
|
|
17
|
+
| BLOG_ENABLED | env | axis: false unmounts posts, tags, archives and the feed (pages, menus, redirects stay). | no | true |
|
|
18
|
+
| STAFF_AUTHZ | env | axis: `staff` = any staff account edits; `model_perms` = staff plus the @access mandate per model (`has_perm("cms.<action>_<model>")`). Anything else is check E002. | no | staff |
|
|
19
|
+
| LOCALES | settings | locales content may be written in; must contain DEFAULT_LOCALE (E003). | no | ["en"] |
|
|
20
|
+
| DEFAULT_LOCALE | env | last step of every fallback chain; the locale of seed pages. | no | en |
|
|
21
|
+
| LOCALE_FALLBACKS | settings | `{"de-at": ["de"]}`: fallbacks tried before DEFAULT_LOCALE; every name must be in LOCALES (E003). | no | {} |
|
|
22
|
+
| BLOCK_TYPES | settings | `{"<type>": "dotted.path.PydanticModel" or None}` merged over the built-ins (rich_text, hero, faq, gallery, embed, form, listing_rail); None removes one. Checked by E001. | no | {} |
|
|
23
|
+
| EMBED_HOSTS | settings | exact hosts an embed block may use (https only); bare host names (E005). | no | youtube, youtube-nocookie, vimeo, google maps hosts |
|
|
24
|
+
| PAGE_TEMPLATES | settings | template keys a page may name; the frontend maps each to a layout. Empty is E004. | no | ["default", "landing", "legal", "faq"] |
|
|
25
|
+
| BLOG_PATH_PREFIX | env | public path prefix of posts (`/blog/<slug>`); pages may not live under it. | no | /blog |
|
|
26
|
+
| WORDS_PER_MINUTE | env | reading-time divisor. | no | 200 |
|
|
27
|
+
| REVISIONS_KEEP | env | revisions kept per page or post; the live and scheduled ones are never pruned. | no | 50 |
|
|
28
|
+
| PAGE_MAX_DEPTH | env | path segments a page may have. | no | 6 |
|
|
29
|
+
| MENU_MAX_DEPTH | env | nesting levels of a menu. | no | 3 |
|
|
30
|
+
| MENU_MAX_ITEMS | env | items per menu. | no | 200 |
|
|
31
|
+
| MAX_BLOCKS | env | blocks per page or post. | no | 200 |
|
|
32
|
+
| MAX_BLOCKS_BYTES | env | serialized size of a block list. | no | 262144 |
|
|
33
|
+
| PREVIEW_TOKEN_TTL_SECONDS | env | lifetime of a signed preview link. | no | 3600 |
|
|
34
|
+
| PREVIEW_URL_TEMPLATE | env | `https://…?token={token}` returned with a preview token; empty = no url. | no | "" |
|
|
35
|
+
| SITE_ORIGIN | env | absolute origin for feed links when the site registry is empty. | no | "" |
|
|
36
|
+
| FEED_ITEMS | env | posts in the RSS/Atom feed. | no | 20 |
|
|
37
|
+
| CACHE_ALIAS | env | Django cache alias of the public read cache; a per-process cache is warning W002. | no | default |
|
|
38
|
+
| CACHE_TTL_SECONDS | env | lifetime of a cached public body (bounds staleness on a per-process cache). | no | 300 |
|
|
39
|
+
| HTTP_MAX_AGE | env | `Cache-Control: public, max-age` of public reads. | no | 60 |
|
|
40
|
+
| MEDIA_REFS_FUNCTION | env | comm Function told which cdn refs content uses (`cdn.refs_sync` contract); empty disables. | no | cdn.refs_sync |
|
|
41
|
+
| MACHINE_TRANSLATE | env | comm Function `{texts, source, target}` → `{texts}` for machine-translated locale variants; empty = off; unreachable is W001. | no | "" |
|
|
42
|
+
| MACHINE_TRANSLATE_TIMEOUT_SECONDS | env | seconds one MACHINE_TRANSLATE call may take (a page is several sequential calls). | no | 300 |
|
|
43
|
+
| MACHINE_TRANSLATE_MAX_TEXT_CHARS | env | chars per text the translation Function accepts; longer rich-text leaves are split at sentence boundaries and rejoined. | no | 5000 |
|
|
44
|
+
| MACHINE_TRANSLATE_MAX_ITEMS | env | texts per translation call. | no | 2000 |
|
|
45
|
+
| MACHINE_TRANSLATE_MAX_CHARS | env | chars per translation call. | no | 200000 |
|
|
46
|
+
| FORM_EXISTS_FUNCTION | env | comm Function `{public_id}` → `{exists, published}` checking a form block on save (unknown refused) and publish (unpublished refused); unreachable = shape check plus a warning; empty disables. | no | forms.form.exists |
|
|
47
|
+
| MEDIA_DESCRIBE_FUNCTION | env | comm Function `{refs}` → `{items, missing}` (`cdn.describe_many`) describing the images of a public page or post answer (`media`, `seo.og_image_url`); unreachable = bare refs only; empty disables. | no | cdn.describe_many |
|
|
48
|
+
| MEDIA_DESCRIBE_MAX_REFS | env | refs described per public answer (one call); the rest stay bare refs. | no | 50 |
|
stapel_cms-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stapel contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: stapel-cms
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Public content: pages, blog, menus and SEO for the Stapel framework
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/usestapel/stapel-cms
|
|
7
|
+
Project-URL: Repository, https://github.com/usestapel/stapel-cms
|
|
8
|
+
Project-URL: Documentation, https://github.com/usestapel/stapel-cms#readme
|
|
9
|
+
Project-URL: Changelog, https://github.com/usestapel/stapel-cms/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issues, https://github.com/usestapel/stapel-cms/issues
|
|
11
|
+
Keywords: django,stapel,cms,pages,blog,menus,seo
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: stapel-core<1.0,>=0.99.3
|
|
27
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Provides-Extra: test
|
|
30
|
+
Requires-Dist: pytest; extra == "test"
|
|
31
|
+
Requires-Dist: pytest-django; extra == "test"
|
|
32
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
33
|
+
Requires-Dist: stapel-tools<1,>=0.84.0; extra == "test"
|
|
34
|
+
Requires-Dist: jsonschema>=4; extra == "test"
|
|
35
|
+
Requires-Dist: stapel-translate<1,>0.8.5; extra == "test"
|
|
36
|
+
Requires-Dist: stapel-forms<1,>0.6.3; extra == "test"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
<!-- Generated by stapel-readme from docs/readme.md + docs/*.json. Do not edit this file; edit docs/readme.md and re-run `make readme`. -->
|
|
40
|
+
|
|
41
|
+
# stapel-cms
|
|
42
|
+
|
|
43
|
+
[](https://github.com/usestapel/stapel-cms/actions/workflows/ci.yml?query=branch%3Amain)
|
|
44
|
+
[](https://app.codecov.io/gh/usestapel/stapel-cms)
|
|
45
|
+
[](https://pypi.org/project/stapel-cms/)
|
|
46
|
+
[](https://pepy.tech/project/stapel-cms)
|
|
47
|
+
[](https://pypi.org/project/stapel-cms/)
|
|
48
|
+
[](https://github.com/usestapel/stapel-cms/blob/main/LICENSE)
|
|
49
|
+
[](https://github.com/usestapel/stapel-cms/blob/main/docs/llms.txt)
|
|
50
|
+
|
|
51
|
+
> Public site content for a Stapel product: pages in a slug tree, a blog (posts, tags, date and tag archives, RSS/Atom), menus (header/footer trees targeting pages, posts, URLs or named frontend routes), SEO fields and a sitemap Function, and redirects written automatically when a published page or post moves. Bodies are typed block lists (rich_text as a ProseMirror/TipTap JSON document, hero, faq, gallery, embed with a host allowlist, a stapel-forms form by id, an opaque listing_rail query) validated by pydantic models from a MERGE registry, so a project adds its own block without forking. Staff write drafts, preview them by a signed link, publish now or on a schedule, keep editing while the published snapshot serves, restore revisions and archive; every publication is a fact. Content is site-scoped through the stapel-core site registry and locale-scoped with a fallback chain; a page can be copied into another locale, optionally through a machine-translation Function. The anonymous read is cached per site and answers conditional requests (ETag, Last-Modified). Not stapel-docs: docs is private workspace documents; cms is what an anonymous visitor reads at a URL of the site.
|
|
52
|
+
|
|
53
|
+
Part of the [Stapel framework](https://github.com/usestapel) — composable Django apps that deploy as a monolith or as microservices without changing module code.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install stapel-cms
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## At a glance
|
|
62
|
+
|
|
63
|
+
| Fact | Value |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Version | `0.1.0` |
|
|
66
|
+
| Python | `>=3.11` (3.11, 3.12, 3.13, 3.14) |
|
|
67
|
+
| HTTP operations | 41 |
|
|
68
|
+
| Config axes | 3 |
|
|
69
|
+
| Usage surface | 10 |
|
|
70
|
+
| Extension points | 9 |
|
|
71
|
+
| Error codes | 71 |
|
|
72
|
+
| Documented flows | 4 |
|
|
73
|
+
| Fleet dependencies | [`stapel-cdn`](https://github.com/usestapel/stapel-cdn) (optional) · [`stapel-core`](https://github.com/usestapel/stapel-core) · [`stapel-forms`](https://github.com/usestapel/stapel-forms) (optional) · [`stapel-translate`](https://github.com/usestapel/stapel-translate) (optional) |
|
|
74
|
+
|
|
75
|
+
## Documentation
|
|
76
|
+
|
|
77
|
+
**Errors:** [English](https://github.com/usestapel/stapel-cms/blob/main/docs/errors.en.md) · [Español](https://github.com/usestapel/stapel-cms/blob/main/docs/errors.es.md) · [Русский](https://github.com/usestapel/stapel-cms/blob/main/docs/errors.ru.md) · [OpenAPI](https://github.com/usestapel/stapel-cms/blob/main/docs/schema.json) · [capabilities.json](https://github.com/usestapel/stapel-cms/blob/main/docs/capabilities.json) · [llms.txt (for agents)](https://github.com/usestapel/stapel-cms/blob/main/docs/llms.txt)
|
|
78
|
+
|
|
79
|
+
## What this is
|
|
80
|
+
|
|
81
|
+
Public site content for a Stapel product: **pages** in a slug tree, a
|
|
82
|
+
**blog** (posts, tags, archives, RSS/Atom), **menus**, **SEO** fields, a
|
|
83
|
+
sitemap Function and **redirects** written for you when a published page
|
|
84
|
+
moves. Staff write typed blocks, preview drafts by a signed link, publish
|
|
85
|
+
now or on a schedule, and restore revisions; the anonymous read is cached per
|
|
86
|
+
site and answers conditional requests. Content is scoped by the stapel-core
|
|
87
|
+
site registry and by locale, with a fallback chain.
|
|
88
|
+
|
|
89
|
+
Not stapel-docs: docs holds private workspace documents; cms holds what an
|
|
90
|
+
anonymous visitor reads at a URL of the site.
|
|
91
|
+
|
|
92
|
+
## Quick start
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
INSTALLED_APPS = [
|
|
96
|
+
# ...
|
|
97
|
+
"stapel_cms",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
STAPEL_CMS = {
|
|
101
|
+
"LOCALES": ["en", "de"],
|
|
102
|
+
"DEFAULT_LOCALE": "en",
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# urls.py
|
|
106
|
+
path("cms/", include("stapel_cms.urls")) # -> /cms/api/v1/...
|
|
107
|
+
|
|
108
|
+
# settings.py — scheduled publication every minute (Celery optional;
|
|
109
|
+
# `manage.py cms_publish_due` runs the same pass)
|
|
110
|
+
from stapel_cms.beat import get_cms_beat_schedule
|
|
111
|
+
CELERY_BEAT_SCHEDULE = {**get_cms_beat_schedule()}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
python manage.py migrate
|
|
116
|
+
python manage.py cms_seed # about, contacts, terms, privacy, faq as drafts
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
A project's own block is one pydantic model and one setting:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from pydantic import Field
|
|
123
|
+
from stapel_cms.blocks import BlockData
|
|
124
|
+
|
|
125
|
+
class PricingTable(BlockData):
|
|
126
|
+
plans: list[str] = Field(min_length=1, max_length=5)
|
|
127
|
+
|
|
128
|
+
STAPEL_CMS = {"BLOCK_TYPES": {"pricing_table": "myapp.blocks.PricingTable"}}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Concepts
|
|
132
|
+
|
|
133
|
+
- **Page / Post** — the row is the staff's working copy; the public reads
|
|
134
|
+
the **published snapshot** (a revision), so edits are invisible until
|
|
135
|
+
published again. Workflow `draft → scheduled → published → archived`;
|
|
136
|
+
every save, publish and schedule appends a revision; restore copies one
|
|
137
|
+
back into the working copy. Optimistic lock on `version`.
|
|
138
|
+
- **Blocks** — `[{type, id, data}]`, each type a pydantic model from a MERGE
|
|
139
|
+
registry: `rich_text` (a ProseMirror/TipTap JSON document — never HTML),
|
|
140
|
+
`hero`, `faq`, `gallery`, `embed` (allowlisted hosts), `form` (a
|
|
141
|
+
stapel-forms id), `listing_rail` (an opaque query for another module).
|
|
142
|
+
Every link passes one safe-URL rule; `javascript:` and friends cannot be
|
|
143
|
+
stored.
|
|
144
|
+
- **Paths and redirects** — a page's path is its ancestors' slugs; moving a
|
|
145
|
+
published page (or renaming a published post) writes `old → new`
|
|
146
|
+
redirects for the whole subtree, chains collapse, a page beats a redirect.
|
|
147
|
+
- **Sites and locales** — every row has a site key (stapel-core site
|
|
148
|
+
registry; `""` on a single host) and a locale; reads fall back
|
|
149
|
+
`requested → LOCALE_FALLBACKS → DEFAULT_LOCALE`; variants share a
|
|
150
|
+
translation group (hreflang alternates). Machine translation is an
|
|
151
|
+
optional Function.
|
|
152
|
+
- **Caching** — public bodies are cached per site and invalidated as a whole
|
|
153
|
+
on every publish; `ETag` / `Last-Modified` answer 304.
|
|
154
|
+
- **GDPR** — staff ids are the only personal data; erasure pseudonymizes
|
|
155
|
+
them and keeps the content.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT — see [LICENSE](https://github.com/usestapel/stapel-cms/blob/main/LICENSE).
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
<sub>This page is assembled by `stapel-readme` from `docs/readme.md` plus the contract artifacts in `docs/`. Edit the prose in `docs/readme.md`; the badges, facts and links above and below it are generated — do not hand-edit `README.md`.</sub>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<!-- Generated by stapel-readme from docs/readme.md + docs/*.json. Do not edit this file; edit docs/readme.md and re-run `make readme`. -->
|
|
2
|
+
|
|
3
|
+
# stapel-cms
|
|
4
|
+
|
|
5
|
+
[](https://github.com/usestapel/stapel-cms/actions/workflows/ci.yml?query=branch%3Amain)
|
|
6
|
+
[](https://app.codecov.io/gh/usestapel/stapel-cms)
|
|
7
|
+
[](https://pypi.org/project/stapel-cms/)
|
|
8
|
+
[](https://pepy.tech/project/stapel-cms)
|
|
9
|
+
[](https://pypi.org/project/stapel-cms/)
|
|
10
|
+
[](https://github.com/usestapel/stapel-cms/blob/main/LICENSE)
|
|
11
|
+
[](https://github.com/usestapel/stapel-cms/blob/main/docs/llms.txt)
|
|
12
|
+
|
|
13
|
+
> Public site content for a Stapel product: pages in a slug tree, a blog (posts, tags, date and tag archives, RSS/Atom), menus (header/footer trees targeting pages, posts, URLs or named frontend routes), SEO fields and a sitemap Function, and redirects written automatically when a published page or post moves. Bodies are typed block lists (rich_text as a ProseMirror/TipTap JSON document, hero, faq, gallery, embed with a host allowlist, a stapel-forms form by id, an opaque listing_rail query) validated by pydantic models from a MERGE registry, so a project adds its own block without forking. Staff write drafts, preview them by a signed link, publish now or on a schedule, keep editing while the published snapshot serves, restore revisions and archive; every publication is a fact. Content is site-scoped through the stapel-core site registry and locale-scoped with a fallback chain; a page can be copied into another locale, optionally through a machine-translation Function. The anonymous read is cached per site and answers conditional requests (ETag, Last-Modified). Not stapel-docs: docs is private workspace documents; cms is what an anonymous visitor reads at a URL of the site.
|
|
14
|
+
|
|
15
|
+
Part of the [Stapel framework](https://github.com/usestapel) — composable Django apps that deploy as a monolith or as microservices without changing module code.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install stapel-cms
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## At a glance
|
|
24
|
+
|
|
25
|
+
| Fact | Value |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Version | `0.1.0` |
|
|
28
|
+
| Python | `>=3.11` (3.11, 3.12, 3.13, 3.14) |
|
|
29
|
+
| HTTP operations | 41 |
|
|
30
|
+
| Config axes | 3 |
|
|
31
|
+
| Usage surface | 10 |
|
|
32
|
+
| Extension points | 9 |
|
|
33
|
+
| Error codes | 71 |
|
|
34
|
+
| Documented flows | 4 |
|
|
35
|
+
| Fleet dependencies | [`stapel-cdn`](https://github.com/usestapel/stapel-cdn) (optional) · [`stapel-core`](https://github.com/usestapel/stapel-core) · [`stapel-forms`](https://github.com/usestapel/stapel-forms) (optional) · [`stapel-translate`](https://github.com/usestapel/stapel-translate) (optional) |
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
**Errors:** [English](https://github.com/usestapel/stapel-cms/blob/main/docs/errors.en.md) · [Español](https://github.com/usestapel/stapel-cms/blob/main/docs/errors.es.md) · [Русский](https://github.com/usestapel/stapel-cms/blob/main/docs/errors.ru.md) · [OpenAPI](https://github.com/usestapel/stapel-cms/blob/main/docs/schema.json) · [capabilities.json](https://github.com/usestapel/stapel-cms/blob/main/docs/capabilities.json) · [llms.txt (for agents)](https://github.com/usestapel/stapel-cms/blob/main/docs/llms.txt)
|
|
40
|
+
|
|
41
|
+
## What this is
|
|
42
|
+
|
|
43
|
+
Public site content for a Stapel product: **pages** in a slug tree, a
|
|
44
|
+
**blog** (posts, tags, archives, RSS/Atom), **menus**, **SEO** fields, a
|
|
45
|
+
sitemap Function and **redirects** written for you when a published page
|
|
46
|
+
moves. Staff write typed blocks, preview drafts by a signed link, publish
|
|
47
|
+
now or on a schedule, and restore revisions; the anonymous read is cached per
|
|
48
|
+
site and answers conditional requests. Content is scoped by the stapel-core
|
|
49
|
+
site registry and by locale, with a fallback chain.
|
|
50
|
+
|
|
51
|
+
Not stapel-docs: docs holds private workspace documents; cms holds what an
|
|
52
|
+
anonymous visitor reads at a URL of the site.
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
INSTALLED_APPS = [
|
|
58
|
+
# ...
|
|
59
|
+
"stapel_cms",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
STAPEL_CMS = {
|
|
63
|
+
"LOCALES": ["en", "de"],
|
|
64
|
+
"DEFAULT_LOCALE": "en",
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# urls.py
|
|
68
|
+
path("cms/", include("stapel_cms.urls")) # -> /cms/api/v1/...
|
|
69
|
+
|
|
70
|
+
# settings.py — scheduled publication every minute (Celery optional;
|
|
71
|
+
# `manage.py cms_publish_due` runs the same pass)
|
|
72
|
+
from stapel_cms.beat import get_cms_beat_schedule
|
|
73
|
+
CELERY_BEAT_SCHEDULE = {**get_cms_beat_schedule()}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python manage.py migrate
|
|
78
|
+
python manage.py cms_seed # about, contacts, terms, privacy, faq as drafts
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
A project's own block is one pydantic model and one setting:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from pydantic import Field
|
|
85
|
+
from stapel_cms.blocks import BlockData
|
|
86
|
+
|
|
87
|
+
class PricingTable(BlockData):
|
|
88
|
+
plans: list[str] = Field(min_length=1, max_length=5)
|
|
89
|
+
|
|
90
|
+
STAPEL_CMS = {"BLOCK_TYPES": {"pricing_table": "myapp.blocks.PricingTable"}}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Concepts
|
|
94
|
+
|
|
95
|
+
- **Page / Post** — the row is the staff's working copy; the public reads
|
|
96
|
+
the **published snapshot** (a revision), so edits are invisible until
|
|
97
|
+
published again. Workflow `draft → scheduled → published → archived`;
|
|
98
|
+
every save, publish and schedule appends a revision; restore copies one
|
|
99
|
+
back into the working copy. Optimistic lock on `version`.
|
|
100
|
+
- **Blocks** — `[{type, id, data}]`, each type a pydantic model from a MERGE
|
|
101
|
+
registry: `rich_text` (a ProseMirror/TipTap JSON document — never HTML),
|
|
102
|
+
`hero`, `faq`, `gallery`, `embed` (allowlisted hosts), `form` (a
|
|
103
|
+
stapel-forms id), `listing_rail` (an opaque query for another module).
|
|
104
|
+
Every link passes one safe-URL rule; `javascript:` and friends cannot be
|
|
105
|
+
stored.
|
|
106
|
+
- **Paths and redirects** — a page's path is its ancestors' slugs; moving a
|
|
107
|
+
published page (or renaming a published post) writes `old → new`
|
|
108
|
+
redirects for the whole subtree, chains collapse, a page beats a redirect.
|
|
109
|
+
- **Sites and locales** — every row has a site key (stapel-core site
|
|
110
|
+
registry; `""` on a single host) and a locale; reads fall back
|
|
111
|
+
`requested → LOCALE_FALLBACKS → DEFAULT_LOCALE`; variants share a
|
|
112
|
+
translation group (hreflang alternates). Machine translation is an
|
|
113
|
+
optional Function.
|
|
114
|
+
- **Caching** — public bodies are cached per site and invalidated as a whole
|
|
115
|
+
on every publish; `ETag` / `Last-Modified` answer 304.
|
|
116
|
+
- **GDPR** — staff ids are the only personal data; erasure pseudonymizes
|
|
117
|
+
them and keeps the content.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT — see [LICENSE](https://github.com/usestapel/stapel-cms/blob/main/LICENSE).
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
<sub>This page is assembled by `stapel-readme` from `docs/readme.md` plus the contract artifacts in `docs/`. Edit the prose in `docs/readme.md`; the badges, facts and links above and below it are generated — do not hand-edit `README.md`.</sub>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""stapel-cms — Public content: pages, blog, menus and SEO for the Stapel framework.
|
|
2
|
+
|
|
3
|
+
Public API (lazily exported, PEP 562 — importing this package never pulls
|
|
4
|
+
in Django or requires configured settings):
|
|
5
|
+
|
|
6
|
+
- ``cms_settings`` — resolved app settings (``stapel_cms.conf``).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"cms_settings",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
# name -> submodule that defines it. Resolution is deferred until first
|
|
14
|
+
# attribute access so that `import stapel_cms` stays Django-free.
|
|
15
|
+
_LAZY_EXPORTS = {
|
|
16
|
+
"cms_settings": ".conf",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def __getattr__(name):
|
|
21
|
+
if name in _LAZY_EXPORTS:
|
|
22
|
+
from importlib import import_module
|
|
23
|
+
|
|
24
|
+
value = getattr(import_module(_LAZY_EXPORTS[name], __name__), name)
|
|
25
|
+
globals()[name] = value # cache for subsequent lookups
|
|
26
|
+
return value
|
|
27
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def __dir__():
|
|
31
|
+
return sorted(set(globals()) | set(__all__))
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""stapel-cms capabilities.json emitter — thin shim over stapel_tools.capabilities."""
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from stapel_tools.capabilities import axis_group_rules, run_capabilities_cli
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main(argv=None):
|
|
8
|
+
from stapel_cms._codegen import _configure
|
|
9
|
+
|
|
10
|
+
_configure()
|
|
11
|
+
from stapel_cms.conf import DEFAULTS
|
|
12
|
+
from stapel_cms.urls import GATE_REGISTRY
|
|
13
|
+
|
|
14
|
+
# CTO-facing axes: BLOG_ENABLED (unmounts the blog routes), STAFF_AUTHZ
|
|
15
|
+
# (who may edit) and EMBED_HOSTS (which embeds render; published to
|
|
16
|
+
# clients in the resolve answer's meta). BLOCK_TYPES is the extension seam.
|
|
17
|
+
axes = {"BLOG_ENABLED", "STAFF_AUTHZ", "EMBED_HOSTS"}
|
|
18
|
+
return run_capabilities_cli(
|
|
19
|
+
argv,
|
|
20
|
+
repo=Path(__file__).resolve().parent,
|
|
21
|
+
canonical_prefix="/cms/api/v1",
|
|
22
|
+
defaults=DEFAULTS,
|
|
23
|
+
registry=GATE_REGISTRY,
|
|
24
|
+
is_axis=lambda k: k in axes,
|
|
25
|
+
axis_group=axis_group_rules(exact={"BLOG_ENABLED": "cms.blog", "STAFF_AUTHZ": "cms.staff",
|
|
26
|
+
"EMBED_HOSTS": "cms.embed"}),
|
|
27
|
+
prog="stapel-cms-capabilities",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == "__main__":
|
|
32
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""stapel-cms contract-emission harness (contract-pipeline.md §2-3).
|
|
2
|
+
|
|
3
|
+
Emits the module's own contract triad into ``docs/`` from a single-module
|
|
4
|
+
``{cms + core}`` Django instance mounted at the canonical
|
|
5
|
+
``cms/api/v1/`` prefix:
|
|
6
|
+
|
|
7
|
+
docs/schema.json drf-spectacular OpenAPI, this module only, canonical prefix
|
|
8
|
+
docs/flows.json generate_flow_docs machine artifact ([] — no @flow_step here)
|
|
9
|
+
docs/errors.json generate_error_keys registry
|
|
10
|
+
|
|
11
|
+
The *mechanism* is stapel_tools.codegen (shared, unchanged); this file is the
|
|
12
|
+
thin per-module *config* that wires the module's settings + canonical mount.
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
python -m stapel_cms._codegen --out docs # `make contract`
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import os
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _configure() -> None:
|
|
26
|
+
"""Configure + boot the single-module Django instance for emission."""
|
|
27
|
+
repo_root = os.path.dirname(os.path.abspath(__file__))
|
|
28
|
+
sys.path[:] = [p for p in sys.path if os.path.abspath(p or os.getcwd()) != repo_root]
|
|
29
|
+
|
|
30
|
+
from django.conf import settings
|
|
31
|
+
|
|
32
|
+
if not settings.configured:
|
|
33
|
+
from stapel_cms._codegen_settings import settings_kwargs
|
|
34
|
+
|
|
35
|
+
settings.configure(
|
|
36
|
+
**settings_kwargs(root_urlconf="stapel_cms.codegen_urls", contract=True)
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
import django
|
|
40
|
+
|
|
41
|
+
django.setup()
|
|
42
|
+
|
|
43
|
+
from drf_spectacular.settings import spectacular_settings
|
|
44
|
+
|
|
45
|
+
from stapel_cms._codegen_settings import CODEGEN_SCHEMA_PATH_PREFIX
|
|
46
|
+
|
|
47
|
+
spectacular_settings.SCHEMA_PATH_PREFIX = CODEGEN_SCHEMA_PATH_PREFIX
|
|
48
|
+
|
|
49
|
+
# Stable enum component names (stapel-schema-lint SCH004).
|
|
50
|
+
from drf_spectacular.plumbing import _load_enum_name_overrides
|
|
51
|
+
|
|
52
|
+
from stapel_cms._codegen_settings import enum_name_overrides
|
|
53
|
+
|
|
54
|
+
spectacular_settings.ENUM_NAME_OVERRIDES = enum_name_overrides()
|
|
55
|
+
_load_enum_name_overrides.cache_clear()
|
|
56
|
+
|
|
57
|
+
# Register drf-spectacular's JWT cookie-auth extension explicitly (a real
|
|
58
|
+
# host triggers this as a side effect of wiring its Swagger URLs). Without
|
|
59
|
+
# it, the protected endpoints
|
|
60
|
+
# would emit without their `security: [{"JWTCookieAuth": []}]` entry — a
|
|
61
|
+
# real contract gap. Applied per stapel-calendar's precedent.
|
|
62
|
+
from stapel_core.django.openapi.swagger import _register_jwt_auth_extension
|
|
63
|
+
|
|
64
|
+
_register_jwt_auth_extension()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _require_python_312() -> None:
|
|
68
|
+
"""Abort emission if not running the pinned 3.12 interpreter.
|
|
69
|
+
|
|
70
|
+
drf-spectacular's rendering of component descriptions (``Optional[X]`` vs
|
|
71
|
+
``X | None``) depends on the Python minor version — contracts emitted on
|
|
72
|
+
anything other than 3.12 (the CI/monolith pin) produce false diffs.
|
|
73
|
+
"""
|
|
74
|
+
if sys.version_info[:2] != (3, 12):
|
|
75
|
+
got = f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
76
|
+
raise SystemExit(
|
|
77
|
+
f"stapel-cms contract emission ABORTED: running Python {got}, "
|
|
78
|
+
"but contracts must be emitted on Python 3.12 (the CI/monolith "
|
|
79
|
+
"pin). drf-spectacular renders component descriptions (Optional[X] "
|
|
80
|
+
"vs X | None) differently across Python minor versions, so emitting "
|
|
81
|
+
"on any other minor produces false diffs against the committed "
|
|
82
|
+
"docs/*.json. Re-run under a 3.12 interpreter."
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def main(argv: list[str] | None = None) -> int:
|
|
87
|
+
_require_python_312()
|
|
88
|
+
|
|
89
|
+
parser = argparse.ArgumentParser(
|
|
90
|
+
prog="stapel-cms-contract",
|
|
91
|
+
description="Emit this module's contract triad (schema.json + flows.json "
|
|
92
|
+
"+ errors.json) into --out, canonical /cms/api/v1/ prefix.",
|
|
93
|
+
)
|
|
94
|
+
parser.add_argument(
|
|
95
|
+
"--out",
|
|
96
|
+
default="docs",
|
|
97
|
+
help="Output directory for the triad (default: docs).",
|
|
98
|
+
)
|
|
99
|
+
args = parser.parse_args(argv)
|
|
100
|
+
|
|
101
|
+
_configure()
|
|
102
|
+
|
|
103
|
+
from stapel_tools.codegen import emit_errors, emit_flows, emit_schema
|
|
104
|
+
|
|
105
|
+
out = Path(args.out)
|
|
106
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
paths = emit_schema(out / "schema.json")
|
|
108
|
+
# Profile 2 goes to its own file: docs/schema.json is what stapel-react's
|
|
109
|
+
# generators read, and stays profile 1.
|
|
110
|
+
emit_schema(out / "schema.v2.json", contract_profile=2)
|
|
111
|
+
flows = emit_flows(out / "flows.json")
|
|
112
|
+
errors = emit_errors(out / "errors.json")
|
|
113
|
+
|
|
114
|
+
print(
|
|
115
|
+
f"stapel-cms contract: {paths} paths, {flows} flows, {errors} error keys "
|
|
116
|
+
f"→ {out}/",
|
|
117
|
+
file=sys.stderr,
|
|
118
|
+
)
|
|
119
|
+
return 0
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Single-module Django settings shared by the test suite and contract emission.
|
|
2
|
+
|
|
3
|
+
One copy, so the harness that emits ``docs/schema.json`` and the tests that
|
|
4
|
+
prove it can never drift in INSTALLED_APPS or comm config. The production
|
|
5
|
+
``REST_FRAMEWORK`` (exception handler, schema class) is used by both: the
|
|
6
|
+
error envelope the tests assert is the one a host serves.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def settings_kwargs(
|
|
12
|
+
*,
|
|
13
|
+
root_urlconf: str = "stapel_cms.tests.urls",
|
|
14
|
+
contract: bool = False,
|
|
15
|
+
neighbours: bool = False,
|
|
16
|
+
) -> dict:
|
|
17
|
+
"""``neighbours=True`` (the test suite) also installs whichever neighbour
|
|
18
|
+
modules cms reaches by Function name are importable (stapel-forms,
|
|
19
|
+
stapel-translate), so the seams are proved against the real providers.
|
|
20
|
+
Contract emission never installs them: the contract is cms's alone."""
|
|
21
|
+
rest_framework = {
|
|
22
|
+
"DEFAULT_RENDERER_CLASSES": ["rest_framework.renderers.JSONRenderer"],
|
|
23
|
+
"DEFAULT_SCHEMA_CLASS": "stapel_core.django.openapi.schemas.PermissionAwareAutoSchema",
|
|
24
|
+
"EXCEPTION_HANDLER": "stapel_core.django.api.errors.stapel_exception_handler",
|
|
25
|
+
}
|
|
26
|
+
if contract:
|
|
27
|
+
rest_framework.update({
|
|
28
|
+
"DEFAULT_AUTHENTICATION_CLASSES": [
|
|
29
|
+
"stapel_core.django.jwt.authentication.JWTCookieAuthentication",
|
|
30
|
+
],
|
|
31
|
+
"DEFAULT_PERMISSION_CLASSES": [
|
|
32
|
+
"stapel_core.django.api.permissions.IsServiceRequest",
|
|
33
|
+
"stapel_core.django.api.permissions.IsSuperUser",
|
|
34
|
+
],
|
|
35
|
+
"DEFAULT_RENDERER_CLASSES": [
|
|
36
|
+
"rest_framework.renderers.JSONRenderer",
|
|
37
|
+
"rest_framework.renderers.BrowsableAPIRenderer",
|
|
38
|
+
],
|
|
39
|
+
})
|
|
40
|
+
return dict(
|
|
41
|
+
SECRET_KEY="test-secret-key-not-for-production",
|
|
42
|
+
DEBUG=False,
|
|
43
|
+
INSTALLED_APPS=[
|
|
44
|
+
"django.contrib.contenttypes",
|
|
45
|
+
"django.contrib.auth",
|
|
46
|
+
"django.contrib.sessions",
|
|
47
|
+
"django.contrib.admin",
|
|
48
|
+
"django.contrib.messages",
|
|
49
|
+
"stapel_core.django.apps.CommonDjangoConfig",
|
|
50
|
+
"stapel_core.django.users",
|
|
51
|
+
"rest_framework",
|
|
52
|
+
"drf_spectacular",
|
|
53
|
+
"stapel_cms",
|
|
54
|
+
*(_neighbour_apps() if neighbours and not contract else []),
|
|
55
|
+
],
|
|
56
|
+
AUTH_USER_MODEL="users.User",
|
|
57
|
+
DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}},
|
|
58
|
+
DEFAULT_AUTO_FIELD="django.db.models.BigAutoField",
|
|
59
|
+
USE_TZ=True,
|
|
60
|
+
ROOT_URLCONF=root_urlconf,
|
|
61
|
+
ALLOWED_HOSTS=["*"],
|
|
62
|
+
CACHES={"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}},
|
|
63
|
+
STAPEL_BUS_BACKEND="stapel_core.bus.backends.memory.MemoryBus",
|
|
64
|
+
STAPEL_COMM={
|
|
65
|
+
"OUTBOX_ENABLED": False,
|
|
66
|
+
"ACTION_TRANSPORT": "inprocess",
|
|
67
|
+
"VALIDATE_SCHEMAS": True,
|
|
68
|
+
},
|
|
69
|
+
STAPEL_CMS={"LOCALES": ["en", "de"]},
|
|
70
|
+
TEMPLATES=[{
|
|
71
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
72
|
+
"APP_DIRS": True,
|
|
73
|
+
"OPTIONS": {"context_processors": [
|
|
74
|
+
"django.template.context_processors.request",
|
|
75
|
+
"django.contrib.auth.context_processors.auth",
|
|
76
|
+
"django.contrib.messages.context_processors.messages",
|
|
77
|
+
]},
|
|
78
|
+
}],
|
|
79
|
+
MIDDLEWARE=[
|
|
80
|
+
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
81
|
+
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
82
|
+
"django.contrib.messages.middleware.MessageMiddleware",
|
|
83
|
+
],
|
|
84
|
+
MIGRATION_MODULES={"users": None},
|
|
85
|
+
REST_FRAMEWORK=rest_framework,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _neighbour_apps() -> list[str]:
|
|
90
|
+
from importlib.util import find_spec
|
|
91
|
+
|
|
92
|
+
apps = []
|
|
93
|
+
if find_spec("stapel_translate") is not None:
|
|
94
|
+
apps += ["stapel_core.django.taskstore", "stapel_translate"]
|
|
95
|
+
if find_spec("stapel_forms") is not None:
|
|
96
|
+
apps.append("stapel_forms")
|
|
97
|
+
return apps
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
#: Forced on drf-spectacular's singleton so a single-module instance derives
|
|
101
|
+
#: the same operation ids as a multi-module aggregate.
|
|
102
|
+
CODEGEN_SCHEMA_PATH_PREFIX = "/"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def enum_name_overrides() -> dict:
|
|
106
|
+
"""Stable enum component names (stapel-schema-lint SCH004)."""
|
|
107
|
+
from stapel_cms.models import RedirectSource, Status, TargetType
|
|
108
|
+
from stapel_cms.serializers import CONTENT_WARNING_CODES
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
"CmsStatusEnum": Status,
|
|
112
|
+
"CmsResolveKindEnum": [("page", "page"), ("post", "post"), ("redirect", "redirect")],
|
|
113
|
+
"CmsMenuTargetEnum": TargetType,
|
|
114
|
+
"CmsRedirectSourceEnum": RedirectSource,
|
|
115
|
+
"CmsContentWarningCodeEnum": CONTENT_WARNING_CODES,
|
|
116
|
+
}
|