simple-module-branding 0.0.43__tar.gz → 0.0.44__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.
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/PKG-INFO +6 -6
- simple_module_branding-0.0.44/branding/assets/__init__.py +1 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/assets}/images.py +2 -2
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/assets}/reaper.py +3 -3
- simple_module_branding-0.0.44/branding/constants.py +11 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/contracts/schemas.py +1 -1
- simple_module_branding-0.0.44/branding/core/__init__.py +5 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/constants.py +2 -2
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/service.py +19 -13
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/services.py +5 -5
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/settings.py +3 -3
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/tenant_branding.py +5 -5
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/tenant_definitions.py +2 -2
- simple_module_branding-0.0.44/branding/endpoints/__init__.py +1 -0
- simple_module_branding-0.0.44/branding/endpoints/assets.py +13 -0
- simple_module_branding-0.0.44/branding/images.py +11 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/module.py +11 -11
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/pages/Manage.tsx +9 -9
- simple_module_branding-0.0.44/branding/services.py +11 -0
- simple_module_branding-0.0.44/branding/settings.py +11 -0
- simple_module_branding-0.0.44/branding/tenant_branding.py +13 -0
- simple_module_branding-0.0.44/branding/web/__init__.py +1 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/deps.py +4 -4
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/endpoints/api.py +7 -7
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/endpoints/assets.py +6 -6
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/endpoints/tenant_api.py +12 -12
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/endpoints/views.py +2 -2
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/shared_props.py +4 -4
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/package.json +1 -1
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/pyproject.toml +6 -6
- simple_module_branding-0.0.43/tests/test_images.py → simple_module_branding-0.0.44/tests/assets/images/test_branding_images.py +1 -1
- simple_module_branding-0.0.43/tests/test_logo_dark.py → simple_module_branding-0.0.44/tests/assets/images/test_branding_logo_dark.py +3 -3
- simple_module_branding-0.0.43/tests/test_asset_lifecycle.py → simple_module_branding-0.0.44/tests/assets/reaper/test_branding_asset_lifecycle.py +1 -1
- {simple_module_branding-0.0.43/tests → simple_module_branding-0.0.44/tests/assets/reaper}/test_branding_reap.py +4 -4
- {simple_module_branding-0.0.43/tests → simple_module_branding-0.0.44/tests/assets/reaper}/test_branding_reap_ordering.py +4 -3
- {simple_module_branding-0.0.43/tests → simple_module_branding-0.0.44/tests/core/module}/test_branding.py +7 -5
- {simple_module_branding-0.0.43/tests → simple_module_branding-0.0.44/tests/core/module}/test_branding_menu_permission.py +1 -1
- simple_module_branding-0.0.43/tests/test_menu_section.py → simple_module_branding-0.0.44/tests/core/module/test_branding_menu_section.py +1 -1
- simple_module_branding-0.0.43/tests/test_presets.py → simple_module_branding-0.0.44/tests/core/presets/test_branding_presets.py +5 -5
- simple_module_branding-0.0.43/tests/test_banner.py → simple_module_branding-0.0.44/tests/core/settings/test_branding_banner.py +3 -3
- simple_module_branding-0.0.43/tests/test_design_pack.py → simple_module_branding-0.0.44/tests/core/settings/test_branding_design_pack.py +2 -2
- simple_module_branding-0.0.43/tests/test_footer_links.py → simple_module_branding-0.0.44/tests/core/settings/test_branding_footer_links.py +3 -3
- simple_module_branding-0.0.43/tests/test_footer_text.py → simple_module_branding-0.0.44/tests/core/settings/test_branding_footer_text.py +3 -3
- simple_module_branding-0.0.43/tests/test_tenant_branding.py → simple_module_branding-0.0.44/tests/core/tenant_branding/test_branding_tenant_branding.py +3 -3
- simple_module_branding-0.0.43/tests/test_tenant_branding_assets.py → simple_module_branding-0.0.44/tests/core/tenant_branding/test_branding_tenant_branding_assets.py +5 -5
- simple_module_branding-0.0.43/tests/test_tenant_branding_cost.py → simple_module_branding-0.0.44/tests/core/tenant_branding/test_branding_tenant_branding_cost.py +2 -2
- simple_module_branding-0.0.43/tests/test_ship_review.py → simple_module_branding-0.0.44/tests/core/tenant_branding/test_branding_tenant_review_fixes.py +6 -6
- {simple_module_branding-0.0.43/tests → simple_module_branding-0.0.44/tests/web/endpoints}/test_branding_clear_route_scope.py +1 -1
- {simple_module_branding-0.0.43/tests → simple_module_branding-0.0.44/tests/web/endpoints}/test_branding_platform_files.py +3 -3
- simple_module_branding-0.0.43/tests/test_public_assets.py → simple_module_branding-0.0.44/tests/web/endpoints/test_branding_public_assets.py +1 -1
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/tests-js/color-field.test.tsx +4 -4
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/tests-js/dirty-state.test.tsx +2 -2
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/.gitignore +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/README.md +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/__init__.py +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/contracts/__init__.py +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/presets.py +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/locales/de.json +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/locales/en.json +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/pages/api.generated.ts +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/pages/api.ts +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/py.typed +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/BannerField.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/BrandingPreview.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/ColorField.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/DesignPackField.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/FooterField.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/ImageDropzones.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/PresetField.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/PreviewSurfaces.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/PreviewTabs.tsx +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/dirty.ts +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/ui}/components/hex.ts +0 -0
- {simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/endpoints/__init__.py +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/tests-js/branding_ManageSave.test.tsx +0 -0
- {simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/tsconfig.json +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_branding
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.44
|
|
4
4
|
Summary: Customisable application branding (name, logo, favicon, primary colour) for simple_module apps
|
|
5
5
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Author-email: Anto Subash <antosubash@live.com>
|
|
7
7
|
License-Expression: MIT
|
|
8
8
|
Keywords: branding,simple-module,theming,white-label
|
|
9
9
|
Requires-Python: >=3.12
|
|
10
|
-
Requires-Dist: simple-module-core==0.0.
|
|
11
|
-
Requires-Dist: simple-module-db==0.0.
|
|
12
|
-
Requires-Dist: simple-module-file-storage==0.0.
|
|
13
|
-
Requires-Dist: simple-module-hosting==0.0.
|
|
14
|
-
Requires-Dist: simple-module-settings==0.0.
|
|
10
|
+
Requires-Dist: simple-module-core==0.0.44
|
|
11
|
+
Requires-Dist: simple-module-db==0.0.44
|
|
12
|
+
Requires-Dist: simple-module-file-storage==0.0.44
|
|
13
|
+
Requires-Dist: simple-module-hosting==0.0.44
|
|
14
|
+
Requires-Dist: simple-module-settings==0.0.44
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
|
|
17
17
|
# simple_module_branding
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Branding images: upload validation and reaping files nothing references."""
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/assets}/images.py
RENAMED
|
@@ -18,7 +18,7 @@ from fastapi import HTTPException, UploadFile
|
|
|
18
18
|
|
|
19
19
|
if TYPE_CHECKING:
|
|
20
20
|
from file_storage.contracts.schemas import StoredFileOut
|
|
21
|
-
from file_storage.service import FileStorageService
|
|
21
|
+
from file_storage.files.service import FileStorageService
|
|
22
22
|
|
|
23
23
|
# Raster + icon only. SVG is excluded on purpose: it is an XML document that can
|
|
24
24
|
# carry <script>, so serving one back from our own origin would be stored XSS.
|
|
@@ -111,7 +111,7 @@ async def store_image(
|
|
|
111
111
|
maps the refusal to 413, but branding calls the service directly, so an
|
|
112
112
|
unmapped ``QuotaExceededError`` would surface as a 500.
|
|
113
113
|
"""
|
|
114
|
-
from file_storage.
|
|
114
|
+
from file_storage.multipart.support import QuotaExceededError
|
|
115
115
|
|
|
116
116
|
try:
|
|
117
117
|
return await storage.upload(file, platform=platform)
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/assets}/reaper.py
RENAMED
|
@@ -26,7 +26,7 @@ from typing import TYPE_CHECKING
|
|
|
26
26
|
from simple_module_db import tenant_context
|
|
27
27
|
from simple_module_db.callbacks import register_on_commit
|
|
28
28
|
|
|
29
|
-
from branding.constants import PACKAGE, TENANT_IMAGE_FIELDS
|
|
29
|
+
from branding.core.constants import PACKAGE, TENANT_IMAGE_FIELDS
|
|
30
30
|
|
|
31
31
|
if TYPE_CHECKING:
|
|
32
32
|
from fastapi import FastAPI
|
|
@@ -40,7 +40,7 @@ _IMAGE_KEYS = frozenset(f"{PACKAGE}.{name}" for name in TENANT_IMAGE_FIELDS)
|
|
|
40
40
|
async def referenced_ids(db: AsyncSession, tenant_id: str | None) -> set[str]:
|
|
41
41
|
"""File ids the owner's image fields hold (``None`` = the system's)."""
|
|
42
42
|
from settings.contracts.schemas import SettingScope
|
|
43
|
-
from settings.service import SettingService
|
|
43
|
+
from settings.core.service import SettingService
|
|
44
44
|
|
|
45
45
|
scope, scope_id = (SettingScope.TENANT, tenant_id) if tenant_id else (SettingScope.SYSTEM, "")
|
|
46
46
|
rows = await SettingService(db).list_by_scope_unmasked(scope, scope_id)
|
|
@@ -58,7 +58,7 @@ def schedule_reap(app: FastAPI, db: AsyncSession, file_id: str, *, tenant_id: st
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
async def reap(app: FastAPI, file_id: str, *, tenant_id: str | None) -> None:
|
|
61
|
-
from file_storage.service import FileStorageService
|
|
61
|
+
from file_storage.files.service import FileStorageService
|
|
62
62
|
|
|
63
63
|
try:
|
|
64
64
|
parsed = uuid.UUID(file_id)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`branding.core.constants`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("branding.constants", remove_in="0.0.46", use="branding.core.constants")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("branding.core.constants")
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/constants.py
RENAMED
|
@@ -69,7 +69,7 @@ DESIGN_PACK_ERROR: Final = (
|
|
|
69
69
|
"not starting with a dash) or empty"
|
|
70
70
|
)
|
|
71
71
|
|
|
72
|
-
# Image upload guard-rails live in branding.images (allow-list, size ceiling and
|
|
72
|
+
# Image upload guard-rails live in branding.assets.images (allow-list, size ceiling and
|
|
73
73
|
# magic-number sniffing), which owns the whole "is this really an image?" question.
|
|
74
74
|
|
|
75
75
|
# ── Public asset routes ────────────────────────────────────────────────
|
|
@@ -79,7 +79,7 @@ DESIGN_PACK_ERROR: Final = (
|
|
|
79
79
|
# page and every ``<link rel="icon">`` are exactly where the logo has to show.
|
|
80
80
|
# Only the two ids currently stored in branding settings are served here, so
|
|
81
81
|
# this is not a way to read arbitrary files out of file_storage.
|
|
82
|
-
#: One-click look. ``{key}`` names a preset from ``branding.presets``.
|
|
82
|
+
#: One-click look. ``{key}`` names a preset from ``branding.core.presets``.
|
|
83
83
|
PATH_PRESET: Final = "/presets/{key}"
|
|
84
84
|
|
|
85
85
|
PATH_LOGO: Final = "/logo"
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/service.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Branding service — reads current branding and applies admin changes.
|
|
2
2
|
|
|
3
3
|
There is no branding DB table: values live in the shared settings store. Writes
|
|
4
|
-
go through ``settings.reload.apply_changes_and_reload`` which validates against
|
|
4
|
+
go through ``settings.module_settings.reload.apply_changes_and_reload`` which validates against
|
|
5
5
|
``BrandingSettings``, persists (SYSTEM scope), hot-swaps ``app.state.branding``
|
|
6
6
|
and publishes ``SettingsReloaded``.
|
|
7
7
|
"""
|
|
@@ -10,17 +10,23 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
from typing import TYPE_CHECKING, Any, cast
|
|
12
12
|
|
|
13
|
-
from branding.
|
|
13
|
+
from branding.assets.reaper import schedule_reap
|
|
14
14
|
from branding.contracts.schemas import BrandingOut
|
|
15
|
-
from branding.
|
|
16
|
-
|
|
15
|
+
from branding.core.constants import (
|
|
16
|
+
FAVICON_URL,
|
|
17
|
+
LOGO_DARK_URL,
|
|
18
|
+
LOGO_URL,
|
|
19
|
+
PACKAGE,
|
|
20
|
+
TENANT_IMAGE_FIELDS,
|
|
21
|
+
)
|
|
22
|
+
from branding.web.shared_props import asset_url
|
|
17
23
|
|
|
18
24
|
if TYPE_CHECKING:
|
|
19
25
|
from fastapi import FastAPI
|
|
20
|
-
from file_storage.service import FileStorageService
|
|
26
|
+
from file_storage.files.service import FileStorageService
|
|
21
27
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
22
28
|
|
|
23
|
-
from branding.settings import BrandingSettings
|
|
29
|
+
from branding.core.settings import BrandingSettings
|
|
24
30
|
|
|
25
31
|
|
|
26
32
|
def to_out(settings: BrandingSettings) -> BrandingOut:
|
|
@@ -64,9 +70,9 @@ class BrandingService:
|
|
|
64
70
|
"""Persist and hot-swap the given field changes, then return current."""
|
|
65
71
|
# Plugin→plugin imports (settings is a declared dependency); kept local
|
|
66
72
|
# so import order during discovery stays tolerant.
|
|
67
|
-
from settings.
|
|
68
|
-
from settings.
|
|
69
|
-
from settings.store import SettingsStore
|
|
73
|
+
from settings.core.service import SettingService
|
|
74
|
+
from settings.module_settings.reload import apply_changes_and_reload
|
|
75
|
+
from settings.module_settings.store import SettingsStore
|
|
70
76
|
|
|
71
77
|
# With the bus, so the write publishes ``settings.values`` and other
|
|
72
78
|
# workers' merged tenant caches (which inherit system values) drop.
|
|
@@ -84,18 +90,18 @@ class BrandingService:
|
|
|
84
90
|
|
|
85
91
|
Every upload mints a new ``file_storage`` id, so the file we stop
|
|
86
92
|
referencing here would otherwise sit in the store forever. The reap is
|
|
87
|
-
queued for after the commit (:mod:`branding.reaper`): deleting the
|
|
93
|
+
queued for after the commit (:mod:`branding.assets.reaper`): deleting the
|
|
88
94
|
bytes in the request would leave a rolled-back setting pointing at a
|
|
89
95
|
file that is gone. A file another system image field still references
|
|
90
96
|
(logo and dark logo sharing one upload) is kept.
|
|
91
97
|
"""
|
|
92
98
|
# The pre-save value comes from the DB-backed settings, not app.state:
|
|
93
99
|
# the in-process object only changes after commit.
|
|
94
|
-
from settings.service import SettingService
|
|
95
|
-
from settings.store import SettingsStore
|
|
100
|
+
from settings.core.service import SettingService
|
|
101
|
+
from settings.module_settings.store import SettingsStore
|
|
96
102
|
from simple_module_core.settings_hydrate import hydrate_settings
|
|
97
103
|
|
|
98
|
-
from branding.settings import BrandingSettings
|
|
104
|
+
from branding.core.settings import BrandingSettings
|
|
99
105
|
|
|
100
106
|
before = await hydrate_settings(
|
|
101
107
|
BrandingSettings, SettingsStore(SettingService(self.db)), PACKAGE, lenient=True
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/services.py
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Stored as ``app.state.branding`` by
|
|
4
4
|
:meth:`BrandingModule.register_settings` (via ``register_module_settings``).
|
|
5
|
-
``settings`` is hot-swapped by ``settings.reload.apply_changes_and_reload`` when
|
|
5
|
+
``settings`` is hot-swapped by ``settings.module_settings.reload.apply_changes_and_reload`` when
|
|
6
6
|
an admin saves changes.
|
|
7
7
|
"""
|
|
8
8
|
|
|
@@ -10,8 +10,8 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
from dataclasses import dataclass, field
|
|
12
12
|
|
|
13
|
-
from branding.settings import BrandingSettings
|
|
14
|
-
from branding.tenant_branding import TenantCache
|
|
13
|
+
from branding.core.settings import BrandingSettings
|
|
14
|
+
from branding.core.tenant_branding import TenantCache
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
@dataclass
|
|
@@ -32,7 +32,7 @@ class BrandingServices:
|
|
|
32
32
|
reads ``settings.app_name``. Keeps the SM009 framework→plugin boundary
|
|
33
33
|
intact — branding owns the URL, the framework only forwards it.
|
|
34
34
|
"""
|
|
35
|
-
from branding.constants import FAVICON_URL
|
|
36
|
-
from branding.shared_props import asset_url
|
|
35
|
+
from branding.core.constants import FAVICON_URL
|
|
36
|
+
from branding.web.shared_props import asset_url
|
|
37
37
|
|
|
38
38
|
return asset_url(FAVICON_URL, self.settings.favicon_file_id)
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/settings.py
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The four values an administrator can customise (app name, logo, favicon,
|
|
4
4
|
primary colour) are stored in the shared settings store at SYSTEM scope,
|
|
5
5
|
hydrated into ``app.state.branding.settings`` at boot, and hot-swapped on save
|
|
6
|
-
through ``settings.reload.apply_changes_and_reload``.
|
|
6
|
+
through ``settings.module_settings.reload.apply_changes_and_reload``.
|
|
7
7
|
|
|
8
8
|
Logo/favicon are stored as ``file_storage`` UUIDs (empty string = unset); the
|
|
9
9
|
frontend derives a download URL from the id.
|
|
@@ -15,7 +15,8 @@ from pydantic import Field, field_validator
|
|
|
15
15
|
from pydantic_settings import SettingsConfigDict
|
|
16
16
|
from simple_module_core.settings_base import DbBackedSettings
|
|
17
17
|
|
|
18
|
-
from branding.
|
|
18
|
+
from branding.contracts.schemas import FooterLink, bounded_footer_links
|
|
19
|
+
from branding.core.constants import (
|
|
19
20
|
BANNER_SEVERITY_INFO,
|
|
20
21
|
DESIGN_PACK_ERROR,
|
|
21
22
|
DESIGN_PACK_RE,
|
|
@@ -25,7 +26,6 @@ from branding.constants import (
|
|
|
25
26
|
clean_footer_text,
|
|
26
27
|
normalize_banner_severity,
|
|
27
28
|
)
|
|
28
|
-
from branding.contracts.schemas import FooterLink, bounded_footer_links
|
|
29
29
|
|
|
30
30
|
DEFAULT_APP_NAME = "SimpleModule"
|
|
31
31
|
|
|
@@ -30,12 +30,12 @@ from cachetools import TTLCache
|
|
|
30
30
|
from pydantic import ValidationError
|
|
31
31
|
from simple_module_core.app_state import get_services
|
|
32
32
|
|
|
33
|
-
from branding.constants import PACKAGE, TENANT_CACHE_TTL_SECONDS, TENANT_FIELDS
|
|
34
|
-
from branding.settings import BrandingSettings
|
|
33
|
+
from branding.core.constants import PACKAGE, TENANT_CACHE_TTL_SECONDS, TENANT_FIELDS
|
|
34
|
+
from branding.core.settings import BrandingSettings
|
|
35
35
|
|
|
36
36
|
if TYPE_CHECKING:
|
|
37
37
|
from fastapi import FastAPI
|
|
38
|
-
from settings.service import SettingService
|
|
38
|
+
from settings.core.service import SettingService
|
|
39
39
|
from simple_module_core.invalidation import Invalidation, InvalidationBus
|
|
40
40
|
from starlette.requests import Request
|
|
41
41
|
|
|
@@ -94,8 +94,8 @@ def forget(app: FastAPI, tenant_id: str | None = None) -> None:
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
def subscribe(bus: InvalidationBus, app: FastAPI) -> None:
|
|
97
|
-
from settings.constants import INVALIDATION_CHANNEL
|
|
98
97
|
from settings.contracts.invalidation import parse_invalidation_key
|
|
98
|
+
from settings.core.constants import INVALIDATION_CHANNEL
|
|
99
99
|
|
|
100
100
|
def on_settings_changed(inv: Invalidation) -> None:
|
|
101
101
|
tenant_id, key = parse_invalidation_key(inv.key)
|
|
@@ -138,7 +138,7 @@ async def read_overrides(app: FastAPI, tenant_id: str) -> dict[str, str]:
|
|
|
138
138
|
Only for reads ahead of a request's own work (shared props, the asset
|
|
139
139
|
routes): a request that has already written must use its own session.
|
|
140
140
|
"""
|
|
141
|
-
from settings.service import SettingService
|
|
141
|
+
from settings.core.service import SettingService
|
|
142
142
|
|
|
143
143
|
async with app.state.sm.db.session_factory() as db:
|
|
144
144
|
return await overrides_from(SettingService(db), tenant_id)
|
|
@@ -31,7 +31,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
31
31
|
from pydantic import ValidationError
|
|
32
32
|
from simple_module_core.app_state import get_design_packs
|
|
33
33
|
|
|
34
|
-
from branding.constants import (
|
|
34
|
+
from branding.core.constants import (
|
|
35
35
|
IMAGE_KEY_GENERIC_WRITE_ERROR,
|
|
36
36
|
PACKAGE,
|
|
37
37
|
ROUTE_PREFIX,
|
|
@@ -39,7 +39,7 @@ from branding.constants import (
|
|
|
39
39
|
TENANT_FIELDS,
|
|
40
40
|
TENANT_IMAGE_FIELDS,
|
|
41
41
|
)
|
|
42
|
-
from branding.settings import BrandingSettings
|
|
42
|
+
from branding.core.settings import BrandingSettings
|
|
43
43
|
|
|
44
44
|
if TYPE_CHECKING:
|
|
45
45
|
from fastapi import FastAPI
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Deprecated package path: the endpoints moved to :mod:`branding.web.endpoints` (module layout)."""
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Moved to :mod:`branding.web.endpoints.assets`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module(
|
|
11
|
+
"branding.endpoints.assets", remove_in="0.0.46", use="branding.web.endpoints.assets"
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = importlib.import_module("branding.web.endpoints.assets")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`branding.assets.images`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("branding.images", remove_in="0.0.46", use="branding.assets.images")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("branding.assets.images")
|
|
@@ -17,8 +17,8 @@ from simple_module_core.module import ModuleBase, ModuleMeta
|
|
|
17
17
|
from simple_module_core.permissions import PermissionRegistry
|
|
18
18
|
from simple_module_core.public_routes import PublicRouteRegistry
|
|
19
19
|
|
|
20
|
-
from branding import constants
|
|
21
|
-
from branding.constants import MENU_URL
|
|
20
|
+
from branding.core import constants
|
|
21
|
+
from branding.core.constants import MENU_URL
|
|
22
22
|
|
|
23
23
|
if TYPE_CHECKING:
|
|
24
24
|
from simple_module_core.invalidation import InvalidationBus
|
|
@@ -38,8 +38,8 @@ class BrandingModule(ModuleBase):
|
|
|
38
38
|
def register_settings(self, app: FastAPI) -> None:
|
|
39
39
|
from simple_module_core.module_settings import register_module_settings
|
|
40
40
|
|
|
41
|
-
from branding.services import BrandingServices
|
|
42
|
-
from branding.settings import BrandingSettings
|
|
41
|
+
from branding.core.services import BrandingServices
|
|
42
|
+
from branding.core.settings import BrandingSettings
|
|
43
43
|
|
|
44
44
|
register_module_settings(
|
|
45
45
|
app,
|
|
@@ -52,12 +52,12 @@ class BrandingModule(ModuleBase):
|
|
|
52
52
|
)
|
|
53
53
|
# Tenants may override a subset for themselves (#373), through
|
|
54
54
|
# settings' tenant surface; resolved per request by tenant_branding.
|
|
55
|
-
from branding.tenant_definitions import register_tenant_definitions
|
|
55
|
+
from branding.core.tenant_definitions import register_tenant_definitions
|
|
56
56
|
|
|
57
57
|
register_tenant_definitions(app)
|
|
58
58
|
|
|
59
59
|
def register_invalidations(self, bus: InvalidationBus, app: FastAPI) -> None:
|
|
60
|
-
from branding.tenant_branding import subscribe
|
|
60
|
+
from branding.core.tenant_branding import subscribe
|
|
61
61
|
|
|
62
62
|
subscribe(bus, app)
|
|
63
63
|
|
|
@@ -97,10 +97,10 @@ class BrandingModule(ModuleBase):
|
|
|
97
97
|
)
|
|
98
98
|
|
|
99
99
|
def register_routes(self, api_router: APIRouter, view_router: APIRouter) -> None:
|
|
100
|
-
from branding.endpoints.api import router as api
|
|
101
|
-
from branding.endpoints.assets import router as assets
|
|
102
|
-
from branding.endpoints.tenant_api import router as tenant_api
|
|
103
|
-
from branding.endpoints.views import router as views
|
|
100
|
+
from branding.web.endpoints.api import router as api
|
|
101
|
+
from branding.web.endpoints.assets import router as assets
|
|
102
|
+
from branding.web.endpoints.tenant_api import router as tenant_api
|
|
103
|
+
from branding.web.endpoints.views import router as views
|
|
104
104
|
|
|
105
105
|
api_router.include_router(api)
|
|
106
106
|
# Tenant owners/admins upload their organisation's own images (#373).
|
|
@@ -113,7 +113,7 @@ class BrandingModule(ModuleBase):
|
|
|
113
113
|
async def on_startup(self, app: FastAPI) -> None:
|
|
114
114
|
from simple_module_hosting.shared_props import register_inertia_shared_provider
|
|
115
115
|
|
|
116
|
-
from branding.shared_props import branding_shared_props
|
|
116
|
+
from branding.web.shared_props import branding_shared_props
|
|
117
117
|
|
|
118
118
|
register_inertia_shared_provider(app, branding_shared_props)
|
|
119
119
|
|
|
@@ -10,15 +10,15 @@ import { type ApiResult, apiFetch, apiResult } from '@simple-module-py/ui/lib/ap
|
|
|
10
10
|
import type { SharedProps } from '@simple-module-py/ui/types';
|
|
11
11
|
import { useMemo, useState } from 'react';
|
|
12
12
|
import { toast } from 'sonner';
|
|
13
|
-
import { BannerField, type BannerSeverity } from '../components/BannerField';
|
|
14
|
-
import { ColorField } from '../components/ColorField';
|
|
15
|
-
import { DesignPackField, type DesignPackOption } from '../components/DesignPackField';
|
|
16
|
-
import { type BrandingForm, countBrandingChanges } from '../components/dirty';
|
|
17
|
-
import { FooterField } from '../components/FooterField';
|
|
18
|
-
import { isValidColor, normalizeHex } from '../components/hex';
|
|
19
|
-
import { ImageDropzones, type ImageKind } from '../components/ImageDropzones';
|
|
20
|
-
import { PresetField, type PresetOption } from '../components/PresetField';
|
|
21
|
-
import { PreviewTabs } from '../components/PreviewTabs';
|
|
13
|
+
import { BannerField, type BannerSeverity } from '../ui/components/BannerField';
|
|
14
|
+
import { ColorField } from '../ui/components/ColorField';
|
|
15
|
+
import { DesignPackField, type DesignPackOption } from '../ui/components/DesignPackField';
|
|
16
|
+
import { type BrandingForm, countBrandingChanges } from '../ui/components/dirty';
|
|
17
|
+
import { FooterField } from '../ui/components/FooterField';
|
|
18
|
+
import { isValidColor, normalizeHex } from '../ui/components/hex';
|
|
19
|
+
import { ImageDropzones, type ImageKind } from '../ui/components/ImageDropzones';
|
|
20
|
+
import { PresetField, type PresetOption } from '../ui/components/PresetField';
|
|
21
|
+
import { PreviewTabs } from '../ui/components/PreviewTabs';
|
|
22
22
|
import { api } from './api';
|
|
23
23
|
|
|
24
24
|
/** Matches `BUILTIN_PRESETS[0]` in `branding/presets.py`. */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`branding.core.services`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("branding.services", remove_in="0.0.46", use="branding.core.services")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("branding.core.services")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`branding.core.settings`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("branding.settings", remove_in="0.0.46", use="branding.core.settings")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("branding.core.settings")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Moved to :mod:`branding.core.tenant_branding`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module(
|
|
11
|
+
"branding.tenant_branding", remove_in="0.0.46", use="branding.core.tenant_branding"
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = importlib.import_module("branding.core.tenant_branding")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The HTTP side: request deps, endpoints and the shared-props provider."""
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/web}/deps.py
RENAMED
|
@@ -5,12 +5,12 @@ from __future__ import annotations
|
|
|
5
5
|
from typing import Annotated
|
|
6
6
|
|
|
7
7
|
from fastapi import Depends, Request
|
|
8
|
-
from file_storage.
|
|
9
|
-
from file_storage.
|
|
8
|
+
from file_storage.files.service import FileStorageService
|
|
9
|
+
from file_storage.web.deps import get_file_storage_service
|
|
10
10
|
from simple_module_db.deps import get_db
|
|
11
11
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
12
12
|
|
|
13
|
-
from branding.service import BrandingService
|
|
13
|
+
from branding.core.service import BrandingService
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
async def get_branding_service(
|
|
@@ -20,7 +20,7 @@ async def get_branding_service(
|
|
|
20
20
|
) -> BrandingService:
|
|
21
21
|
# FastAPI caches dependencies per request, so ``storage`` shares this very
|
|
22
22
|
# session; a replaced image is reaped only after it commits (see
|
|
23
|
-
# ``branding.reaper``), so a rollback never strands the setting.
|
|
23
|
+
# ``branding.assets.reaper``), so a rollback never strands the setting.
|
|
24
24
|
return BrandingService(request.app, db, storage)
|
|
25
25
|
|
|
26
26
|
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from fastapi import APIRouter, Depends, HTTPException, Request, UploadFile
|
|
6
|
-
from file_storage.
|
|
7
|
-
from file_storage.
|
|
6
|
+
from file_storage.files.service import FileStorageService
|
|
7
|
+
from file_storage.web.deps import get_file_storage_service
|
|
8
8
|
from simple_module_core.app_state import get_design_packs
|
|
9
9
|
from simple_module_hosting.permissions import RequiresPermission
|
|
10
10
|
|
|
11
|
-
from branding import
|
|
11
|
+
from branding.assets.images import store_image, validate_image
|
|
12
12
|
from branding.contracts.schemas import BrandingOut, BrandingUpdate
|
|
13
|
-
from branding.
|
|
14
|
-
from branding.
|
|
15
|
-
from branding.
|
|
13
|
+
from branding.core import constants
|
|
14
|
+
from branding.core.presets import find_preset
|
|
15
|
+
from branding.web.deps import BrandingServiceDep
|
|
16
16
|
|
|
17
17
|
router = APIRouter()
|
|
18
18
|
|
|
19
19
|
# Branding images are uploaded with ``platform=True``: they are the install's,
|
|
20
20
|
# not the uploading admin's active organisation's, and the anonymous asset
|
|
21
|
-
# routes must find them with no tenant bound (see ``file_storage.scope``).
|
|
21
|
+
# routes must find them with no tenant bound (see ``file_storage.core.scope``).
|
|
22
22
|
|
|
23
23
|
_MANAGE = Depends(RequiresPermission(constants.PERM_MANAGE))
|
|
24
24
|
|
|
@@ -13,7 +13,7 @@ The file id is never taken from the request (``?v=`` is only a cache key):
|
|
|
13
13
|
``tenant_context(tenant)``, so only a row the tenant owns matches;
|
|
14
14
|
* a **system** value is read as a *platform* file (``platform=True``): an
|
|
15
15
|
``all_tenants()`` lookup restricted to rows owned by
|
|
16
|
-
``file_storage.scope.PLATFORM_TENANT_ID``.
|
|
16
|
+
``file_storage.core.scope.PLATFORM_TENANT_ID``.
|
|
17
17
|
|
|
18
18
|
Either way a setting pointed at someone else's file id serves a 404, never
|
|
19
19
|
their file.
|
|
@@ -26,18 +26,18 @@ import uuid
|
|
|
26
26
|
|
|
27
27
|
from fastapi import APIRouter, Depends, HTTPException, Request
|
|
28
28
|
from fastapi.responses import RedirectResponse, StreamingResponse
|
|
29
|
-
from file_storage.
|
|
30
|
-
from file_storage.service import (
|
|
29
|
+
from file_storage.files.service import (
|
|
31
30
|
FileStorageService,
|
|
32
31
|
RedirectDownload,
|
|
33
32
|
StoredFileNotFoundError,
|
|
34
33
|
StreamDownload,
|
|
35
34
|
)
|
|
35
|
+
from file_storage.web.deps import get_file_storage_service
|
|
36
36
|
from simple_module_db import tenant_context
|
|
37
37
|
|
|
38
|
-
from branding import
|
|
39
|
-
from branding.
|
|
40
|
-
from branding.tenant_branding import ResolvedBranding, resolve
|
|
38
|
+
from branding.assets.images import ALLOWED_IMAGE_TYPES, normalize_content_type
|
|
39
|
+
from branding.core import constants
|
|
40
|
+
from branding.core.tenant_branding import ResolvedBranding, resolve
|
|
41
41
|
|
|
42
42
|
router = APIRouter()
|
|
43
43
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
points the tenant's ``branding.<field>`` override at it; ``DELETE`` removes the
|
|
6
6
|
override, so the tenant falls back to the system image. The replaced file is
|
|
7
7
|
reaped in the tenant's own scope once the write commits, unless another of the
|
|
8
|
-
tenant's image fields still references it (:mod:`branding.reaper`).
|
|
8
|
+
tenant's image fields still references it (:mod:`branding.assets.reaper`).
|
|
9
9
|
|
|
10
10
|
Guarded like every other tenant-settings write: ``settings.tenant.edit``
|
|
11
11
|
(tenant owner/admin) and the tenant comes from ``request.state.tenant_id``
|
|
@@ -16,21 +16,21 @@ only. Scalar fields go through settings' generic
|
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
|
|
18
18
|
from fastapi import APIRouter, Depends, HTTPException, Request, UploadFile
|
|
19
|
-
from file_storage.
|
|
20
|
-
from file_storage.
|
|
21
|
-
from settings.constants import PERM_TENANT_EDIT
|
|
19
|
+
from file_storage.files.service import FileStorageService
|
|
20
|
+
from file_storage.web.deps import get_file_storage_service
|
|
22
21
|
from settings.contracts.schemas import SettingScope, SettingUpsert
|
|
23
|
-
from settings.
|
|
24
|
-
from settings.service import SettingService
|
|
25
|
-
from settings.tenant_scope import active_tenant
|
|
22
|
+
from settings.core.constants import PERM_TENANT_EDIT
|
|
23
|
+
from settings.core.service import SettingService
|
|
24
|
+
from settings.core.tenant_scope import active_tenant
|
|
25
|
+
from settings.web.deps import get_setting_service
|
|
26
26
|
from simple_module_hosting.permissions import RequiresPermission
|
|
27
27
|
|
|
28
|
-
from branding.
|
|
28
|
+
from branding.assets.images import store_image, validate_image
|
|
29
|
+
from branding.assets.reaper import schedule_reap
|
|
29
30
|
from branding.contracts.schemas import BrandingOut
|
|
30
|
-
from branding.
|
|
31
|
-
from branding.
|
|
32
|
-
from branding.
|
|
33
|
-
from branding.tenant_branding import merge, overrides_from
|
|
31
|
+
from branding.core.constants import PACKAGE, PATH_TENANT_ASSET, TENANT_ASSETS, TENANT_IMAGE_FIELDS
|
|
32
|
+
from branding.core.service import to_out
|
|
33
|
+
from branding.core.tenant_branding import merge, overrides_from
|
|
34
34
|
|
|
35
35
|
router = APIRouter(dependencies=[Depends(RequiresPermission(PERM_TENANT_EDIT))])
|
|
36
36
|
|
|
@@ -8,8 +8,8 @@ from simple_module_hosting.inertia_deps import InertiaDep
|
|
|
8
8
|
from simple_module_hosting.permissions import RequiresPermission
|
|
9
9
|
from simple_module_inertia import InertiaResponse
|
|
10
10
|
|
|
11
|
-
from branding import constants
|
|
12
|
-
from branding.presets import BUILTIN_PRESETS
|
|
11
|
+
from branding.core import constants
|
|
12
|
+
from branding.core.presets import BUILTIN_PRESETS
|
|
13
13
|
|
|
14
14
|
router = APIRouter()
|
|
15
15
|
|
|
@@ -11,7 +11,7 @@ from typing import TYPE_CHECKING
|
|
|
11
11
|
|
|
12
12
|
from simple_module_hosting.inertia_deps import INERTIA_HEADER
|
|
13
13
|
|
|
14
|
-
from branding.constants import (
|
|
14
|
+
from branding.core.constants import (
|
|
15
15
|
ASSET_VERSION_QUERY_KEY,
|
|
16
16
|
FAVICON_URL,
|
|
17
17
|
LOGO_DARK_URL,
|
|
@@ -21,7 +21,7 @@ from branding.constants import (
|
|
|
21
21
|
if TYPE_CHECKING:
|
|
22
22
|
from starlette.requests import Request
|
|
23
23
|
|
|
24
|
-
from branding.settings import BrandingSettings
|
|
24
|
+
from branding.core.settings import BrandingSettings
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def asset_url(base: str, file_id: str) -> str | None:
|
|
@@ -98,8 +98,8 @@ async def branding_shared_props(request: Request) -> dict:
|
|
|
98
98
|
Defensive — returns ``{}`` if the branding state isn't mounted yet, so a
|
|
99
99
|
half-booted app never errors a page render.
|
|
100
100
|
"""
|
|
101
|
-
from branding.services import BrandingServices
|
|
102
|
-
from branding.tenant_branding import resolve
|
|
101
|
+
from branding.core.services import BrandingServices
|
|
102
|
+
from branding.core.tenant_branding import resolve
|
|
103
103
|
|
|
104
104
|
if getattr(request.app.state, "branding", None) is None or not renders_a_page(request):
|
|
105
105
|
return {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_branding"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.44"
|
|
4
4
|
description = "Customisable application branding (name, logo, favicon, primary colour) for simple_module apps"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -8,11 +8,11 @@ authors = [{ name = "Anto Subash", email = "antosubash@live.com" }]
|
|
|
8
8
|
keywords = ["simple-module", "branding", "theming", "white-label"]
|
|
9
9
|
requires-python = ">=3.12"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"simple_module_core==0.0.
|
|
12
|
-
"simple_module_db==0.0.
|
|
13
|
-
"simple_module_hosting==0.0.
|
|
14
|
-
"simple_module_settings==0.0.
|
|
15
|
-
"simple_module_file_storage==0.0.
|
|
11
|
+
"simple_module_core==0.0.44",
|
|
12
|
+
"simple_module_db==0.0.44",
|
|
13
|
+
"simple_module_hosting==0.0.44",
|
|
14
|
+
"simple_module_settings==0.0.44",
|
|
15
|
+
"simple_module_file_storage==0.0.44",
|
|
16
16
|
]
|
|
17
17
|
|
|
18
18
|
[project.urls]
|
|
@@ -19,10 +19,10 @@ from typing import Any
|
|
|
19
19
|
|
|
20
20
|
import httpx
|
|
21
21
|
import pytest
|
|
22
|
-
from branding.settings import BrandingSettings
|
|
23
|
-
from branding.shared_props import branding_payload
|
|
22
|
+
from branding.core.settings import BrandingSettings
|
|
23
|
+
from branding.web.shared_props import branding_payload
|
|
24
|
+
from file_storage.files.service import FileStorageService, StreamDownload
|
|
24
25
|
from file_storage.models import StoredFile
|
|
25
|
-
from file_storage.service import FileStorageService, StreamDownload
|
|
26
26
|
|
|
27
27
|
_PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 32
|
|
28
28
|
|
|
@@ -14,8 +14,8 @@ from typing import Any
|
|
|
14
14
|
|
|
15
15
|
import httpx
|
|
16
16
|
import pytest
|
|
17
|
+
from file_storage.files.service import FileStorageService, StoredFileNotFoundError
|
|
17
18
|
from file_storage.models import StoredFile
|
|
18
|
-
from file_storage.service import FileStorageService, StoredFileNotFoundError
|
|
19
19
|
|
|
20
20
|
_PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 32
|
|
21
21
|
|
|
@@ -8,12 +8,12 @@ another image field of the same owner still holds must survive.
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
10
|
import pytest
|
|
11
|
-
from branding import tenant_branding
|
|
12
|
-
from branding.
|
|
13
|
-
from branding.
|
|
11
|
+
from branding.core import tenant_branding
|
|
12
|
+
from branding.core.service import BrandingService
|
|
13
|
+
from branding.web.endpoints import tenant_api
|
|
14
14
|
from file_storage.models import StoredFile
|
|
15
15
|
from settings.contracts.schemas import SettingScope, SettingUpsert
|
|
16
|
-
from settings.service import SettingService
|
|
16
|
+
from settings.core.service import SettingService
|
|
17
17
|
from simple_module_db import all_tenants
|
|
18
18
|
from sqlalchemy import select
|
|
19
19
|
|
|
@@ -9,11 +9,12 @@ from __future__ import annotations
|
|
|
9
9
|
import asyncio
|
|
10
10
|
import gc
|
|
11
11
|
|
|
12
|
-
from branding import reaper
|
|
13
|
-
from branding.
|
|
12
|
+
from branding.assets import reaper
|
|
13
|
+
from branding.core import tenant_branding
|
|
14
|
+
from branding.core.tenant_branding import TenantCache
|
|
14
15
|
from file_storage.models import StoredFile
|
|
15
16
|
from settings.contracts.schemas import SettingScope
|
|
16
|
-
from settings.service import SettingService
|
|
17
|
+
from settings.core.service import SettingService
|
|
17
18
|
from simple_module_db import all_tenants
|
|
18
19
|
from sqlalchemy import select
|
|
19
20
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
@@ -7,8 +7,8 @@ from types import SimpleNamespace
|
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
import pytest
|
|
10
|
-
from branding.settings import BrandingSettings
|
|
11
|
-
from branding.shared_props import branding_payload, branding_shared_props
|
|
10
|
+
from branding.core.settings import BrandingSettings
|
|
11
|
+
from branding.web.shared_props import branding_payload, branding_shared_props
|
|
12
12
|
|
|
13
13
|
# ── Unit: settings validation ──────────────────────────────────────────
|
|
14
14
|
|
|
@@ -204,7 +204,9 @@ async def test_logo_upload_sets_logo_url(
|
|
|
204
204
|
assert platform, "branding must act on platform-owned files"
|
|
205
205
|
return SimpleNamespace(id=fake_id)
|
|
206
206
|
|
|
207
|
-
monkeypatch.setattr(
|
|
207
|
+
monkeypatch.setattr(
|
|
208
|
+
"file_storage.files.service.FileStorageService.upload", fake_upload, raising=True
|
|
209
|
+
)
|
|
208
210
|
|
|
209
211
|
resp = await authenticated_client.post(
|
|
210
212
|
"/api/branding/logo",
|
|
@@ -234,8 +236,8 @@ def test_page_constant_matches_view_literal() -> None:
|
|
|
234
236
|
# (the literal is required inline for SM003/SM004 static AST pairing).
|
|
235
237
|
import inspect
|
|
236
238
|
|
|
237
|
-
from branding import constants
|
|
238
|
-
from branding.endpoints import views
|
|
239
|
+
from branding.core import constants
|
|
240
|
+
from branding.web.endpoints import views
|
|
239
241
|
|
|
240
242
|
assert constants._PAGE_MANAGE == "Branding/Manage"
|
|
241
243
|
assert f'"{constants._PAGE_MANAGE}"' in inspect.getsource(views.manage)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Branding navigation follows the page guard rather than role names (#698)."""
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
|
-
from branding.constants import MENU_URL, PERM_VIEW
|
|
4
|
+
from branding.core.constants import MENU_URL, PERM_VIEW
|
|
5
5
|
from branding.module import BrandingModule
|
|
6
6
|
from simple_module_core.menu import MenuRegistry, MenuSection
|
|
7
7
|
|
|
@@ -10,10 +10,10 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
import httpx
|
|
12
12
|
import pytest
|
|
13
|
-
from branding.presets import BUILTIN_PRESETS, PRESET_FIELDS, BrandingPreset, find_preset
|
|
14
|
-
from settings.invalidation import reload_package
|
|
15
|
-
from settings.service import SettingService
|
|
16
|
-
from settings.store import SettingsStore
|
|
13
|
+
from branding.core.presets import BUILTIN_PRESETS, PRESET_FIELDS, BrandingPreset, find_preset
|
|
14
|
+
from settings.core.invalidation import reload_package
|
|
15
|
+
from settings.core.service import SettingService
|
|
16
|
+
from settings.module_settings.store import SettingsStore
|
|
17
17
|
|
|
18
18
|
# ── Unit: definitions ──────────────────────────────────────────────────
|
|
19
19
|
|
|
@@ -48,7 +48,7 @@ def test_every_preset_only_touches_appearance() -> None:
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
def test_every_preset_sets_a_valid_hex_colour() -> None:
|
|
51
|
-
from branding.constants import HEX_COLOR_RE
|
|
51
|
+
from branding.core.constants import HEX_COLOR_RE
|
|
52
52
|
|
|
53
53
|
for preset in BUILTIN_PRESETS:
|
|
54
54
|
colour = preset.values.get("primary_color")
|
|
@@ -11,10 +11,10 @@ from __future__ import annotations
|
|
|
11
11
|
|
|
12
12
|
import httpx
|
|
13
13
|
import pytest
|
|
14
|
-
from branding.constants import MAX_BANNER_MESSAGE_LEN, normalize_banner_severity
|
|
15
14
|
from branding.contracts.schemas import BrandingUpdate
|
|
16
|
-
from branding.
|
|
17
|
-
from branding.
|
|
15
|
+
from branding.core.constants import MAX_BANNER_MESSAGE_LEN, normalize_banner_severity
|
|
16
|
+
from branding.core.settings import BrandingSettings
|
|
17
|
+
from branding.web.shared_props import branding_payload
|
|
18
18
|
|
|
19
19
|
# ── Unit: settings normalise ───────────────────────────────────────────
|
|
20
20
|
|
|
@@ -11,8 +11,8 @@ from __future__ import annotations
|
|
|
11
11
|
import httpx
|
|
12
12
|
import pytest
|
|
13
13
|
from branding.contracts.schemas import BrandingUpdate
|
|
14
|
-
from branding.settings import BrandingSettings
|
|
15
|
-
from branding.shared_props import branding_payload
|
|
14
|
+
from branding.core.settings import BrandingSettings
|
|
15
|
+
from branding.web.shared_props import branding_payload
|
|
16
16
|
from simple_module_core.design_packs import DesignPack
|
|
17
17
|
|
|
18
18
|
_GCA = DesignPack(value="gca", label="Canopy Atlas")
|
|
@@ -9,10 +9,10 @@ with no setting, prop or admin screen that changed it.
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
import pytest
|
|
12
|
-
from branding.constants import MAX_FOOTER_LINKS
|
|
13
12
|
from branding.contracts.schemas import BrandingUpdate, FooterLink
|
|
14
|
-
from branding.
|
|
15
|
-
from branding.
|
|
13
|
+
from branding.core.constants import MAX_FOOTER_LINKS
|
|
14
|
+
from branding.core.settings import BrandingSettings
|
|
15
|
+
from branding.web.shared_props import branding_payload
|
|
16
16
|
from httpx import AsyncClient
|
|
17
17
|
from pydantic import ValidationError
|
|
18
18
|
|
|
@@ -8,10 +8,10 @@ became configurable in #282; this is the line beside them.
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
10
|
import pytest
|
|
11
|
-
from branding.constants import MAX_FOOTER_TEXT_LEN
|
|
12
11
|
from branding.contracts.schemas import BrandingUpdate
|
|
13
|
-
from branding.
|
|
14
|
-
from branding.
|
|
12
|
+
from branding.core.constants import MAX_FOOTER_TEXT_LEN
|
|
13
|
+
from branding.core.settings import BrandingSettings
|
|
14
|
+
from branding.web.shared_props import branding_payload
|
|
15
15
|
from httpx import AsyncClient
|
|
16
16
|
from pydantic import ValidationError
|
|
17
17
|
|
|
@@ -10,11 +10,11 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
import httpx
|
|
12
12
|
import pytest
|
|
13
|
-
from branding import tenant_branding
|
|
14
|
-
from settings.constants import INVALIDATION_CHANNEL
|
|
13
|
+
from branding.core import tenant_branding
|
|
15
14
|
from settings.contracts.invalidation import invalidation_key
|
|
16
15
|
from settings.contracts.schemas import SettingScope, SettingUpsert
|
|
17
|
-
from settings.
|
|
16
|
+
from settings.core.constants import INVALIDATION_CHANNEL
|
|
17
|
+
from settings.core.service import SettingService
|
|
18
18
|
from simple_module_hosting.settings import Settings
|
|
19
19
|
from simple_module_test.database import database_url_for_tests
|
|
20
20
|
|
|
@@ -10,16 +10,16 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
import httpx
|
|
12
12
|
import pytest
|
|
13
|
-
from branding import tenant_branding
|
|
14
|
-
from branding.constants import LOGO_URL
|
|
13
|
+
from branding.core import tenant_branding
|
|
14
|
+
from branding.core.constants import LOGO_URL
|
|
15
|
+
from file_storage.core.scope import PLATFORM_TENANT_ID
|
|
15
16
|
from file_storage.models import StoredFile
|
|
16
|
-
from file_storage.scope import PLATFORM_TENANT_ID
|
|
17
17
|
from settings.contracts.schemas import SettingScope, SettingUpsert
|
|
18
|
-
from settings.service import SettingService
|
|
18
|
+
from settings.core.service import SettingService
|
|
19
19
|
from simple_module_db import all_tenants
|
|
20
20
|
from sqlalchemy import select
|
|
21
|
-
from tenants.host_resolver import forget_hosts
|
|
22
21
|
from tenants.models import Tenant
|
|
22
|
+
from tenants.resolution.host_resolver import forget_hosts
|
|
23
23
|
|
|
24
24
|
_PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 32
|
|
25
25
|
TENANT_LOGO = "/api/branding/tenant/logo"
|
|
@@ -10,8 +10,8 @@ from __future__ import annotations
|
|
|
10
10
|
import asyncio
|
|
11
11
|
|
|
12
12
|
import pytest
|
|
13
|
-
from branding import tenant_branding
|
|
14
|
-
from branding.shared_props import renders_a_page
|
|
13
|
+
from branding.core import tenant_branding
|
|
14
|
+
from branding.web.shared_props import renders_a_page
|
|
15
15
|
from starlette.requests import Request
|
|
16
16
|
|
|
17
17
|
|
|
@@ -4,14 +4,14 @@ per-app cache, system-save invalidation and generic deletes of image keys."""
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
6
|
import httpx
|
|
7
|
-
from branding import tenant_branding
|
|
8
|
-
from branding.services import BrandingServices
|
|
9
|
-
from branding.settings import BrandingSettings
|
|
10
|
-
from branding.tenant_branding import TenantCache, merge
|
|
11
|
-
from settings.constants import INVALIDATION_CHANNEL
|
|
7
|
+
from branding.core import tenant_branding
|
|
8
|
+
from branding.core.services import BrandingServices
|
|
9
|
+
from branding.core.settings import BrandingSettings
|
|
10
|
+
from branding.core.tenant_branding import TenantCache, merge
|
|
12
11
|
from settings.contracts.invalidation import parse_invalidation_key
|
|
13
12
|
from settings.contracts.schemas import SettingScope, SettingUpsert
|
|
14
|
-
from settings.
|
|
13
|
+
from settings.core.constants import INVALIDATION_CHANNEL
|
|
14
|
+
from settings.core.service import SettingService
|
|
15
15
|
from simple_module_db import all_tenants
|
|
16
16
|
from sqlalchemy import select
|
|
17
17
|
|
|
@@ -7,7 +7,7 @@ route cannot touch it, so pointing a SYSTEM-scope refusal there was a dead end.
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
9
|
from settings.contracts.schemas import SettingScope, SettingUpsert
|
|
10
|
-
from settings.service import SettingService
|
|
10
|
+
from settings.core.service import SettingService
|
|
11
11
|
from simple_module_db.stored_settings import SYSTEM_SCOPE_ID
|
|
12
12
|
|
|
13
13
|
KEY = "branding.logo_file_id"
|
|
@@ -14,9 +14,9 @@ import uuid
|
|
|
14
14
|
|
|
15
15
|
import httpx
|
|
16
16
|
import pytest
|
|
17
|
-
from branding.constants import LOGO_URL
|
|
17
|
+
from branding.core.constants import LOGO_URL
|
|
18
|
+
from file_storage.core.scope import PLATFORM_TENANT_ID
|
|
18
19
|
from file_storage.models import StoredFile
|
|
19
|
-
from file_storage.scope import PLATFORM_TENANT_ID
|
|
20
20
|
from simple_module_db import all_tenants
|
|
21
21
|
from sqlalchemy import select
|
|
22
22
|
|
|
@@ -38,7 +38,7 @@ async def _rows(app) -> list[StoredFile]:
|
|
|
38
38
|
async def _give_admin_a_tenant(app) -> str:
|
|
39
39
|
from simple_module_test.fixtures import SETUP_ADMIN_EMAIL
|
|
40
40
|
from tenants.models import Membership, Tenant
|
|
41
|
-
from tenants.resolver import forget
|
|
41
|
+
from tenants.resolution.resolver import forget
|
|
42
42
|
from users.models import User
|
|
43
43
|
|
|
44
44
|
async with app.state.sm.db.session_factory() as session:
|
|
@@ -17,8 +17,8 @@ from typing import Any
|
|
|
17
17
|
|
|
18
18
|
import httpx
|
|
19
19
|
import pytest
|
|
20
|
+
from file_storage.files.service import FileStorageService, StreamDownload
|
|
20
21
|
from file_storage.models import StoredFile
|
|
21
|
-
from file_storage.service import FileStorageService, StreamDownload
|
|
22
22
|
|
|
23
23
|
_PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 32
|
|
24
24
|
|
{simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/tests-js/color-field.test.tsx
RENAMED
|
@@ -14,10 +14,10 @@ configureI18n({
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
import { type PreviewBrand, previewInk } from '../branding/components/BrandingPreview';
|
|
18
|
-
import { ColorField } from '../branding/components/ColorField';
|
|
19
|
-
import { isValidColor, normalizeHex } from '../branding/components/hex';
|
|
20
|
-
import { SignInPreview } from '../branding/components/PreviewSurfaces';
|
|
17
|
+
import { type PreviewBrand, previewInk } from '../branding/ui/components/BrandingPreview';
|
|
18
|
+
import { ColorField } from '../branding/ui/components/ColorField';
|
|
19
|
+
import { isValidColor, normalizeHex } from '../branding/ui/components/hex';
|
|
20
|
+
import { SignInPreview } from '../branding/ui/components/PreviewSurfaces';
|
|
21
21
|
|
|
22
22
|
function Harness({ initial }: { initial: string }) {
|
|
23
23
|
const [value, setValue] = useState(initial);
|
{simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/tests-js/dirty-state.test.tsx
RENAMED
|
@@ -10,8 +10,8 @@ configureI18n({
|
|
|
10
10
|
},
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
import { type BrandingForm, countBrandingChanges } from '../branding/components/dirty';
|
|
14
|
-
import { PresetField } from '../branding/components/PresetField';
|
|
13
|
+
import { type BrandingForm, countBrandingChanges } from '../branding/ui/components/dirty';
|
|
14
|
+
import { PresetField } from '../branding/ui/components/PresetField';
|
|
15
15
|
|
|
16
16
|
const BASELINE: BrandingForm = {
|
|
17
17
|
appName: 'Acme Admin',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/contracts/__init__.py
RENAMED
|
File without changes
|
{simple_module_branding-0.0.43/branding → simple_module_branding-0.0.44/branding/core}/presets.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_branding-0.0.43 → simple_module_branding-0.0.44}/branding/pages/api.generated.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|