Führe die Konfigurationsansicht der Connectoren ein, damit Paperless und IMAP ihre Felder selbst deklarieren.
Das Modul liefert ein Feldmanifest und validiert es; ein leeres Geheimnisfeld behält das gespeicherte. Die Oberfläche rendert die Felder generisch in einer Detailansicht je Zugang mit Prüfstand, Fähigkeiten und Verwendung. Die providerspezifischen Formulare in Sources.jsx entfallen, die flachen API-Felder bleiben als Kompatibilität. Das Standardfach eines IMAP-Kontos öffnet der Picker zuerst. Die Backend-Tests wurden in der Entwicklungsumgebung nicht ausgeführt; der Lauf auf develop steht aus. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c29bd29f34
commit
eb58dce4cd
20 files changed
+1071
-244
No files matched your search
@@ -10,7 +10,7 @@ from uuid import UUID
|
||||
from app.core.errors import not_found, unprocessable
|
||||
from app.retrieval import FilePayload, RetrievalFailure
|
||||
from app.sourcebind import resolve_for_read
|
||||
from app.sourceregistry import SourceModule, register_source, unregister_source
|
||||
from app.sourceregistry import ConfigField, SourceModule, register_source, unregister_source
|
||||
from app.sourceaccess import borrow_original, complete_borrow
|
||||
|
||||
KIND = "sample"
|
||||
@@ -51,13 +51,16 @@ CAPABILITIES = {
|
||||
}
|
||||
|
||||
|
||||
def parse_config(payload: dict) -> tuple[str, dict, str]:
|
||||
config = payload.get("config") or {}
|
||||
catalog = str(config.get("catalog") or "").strip()
|
||||
name = str(payload.get("name") or "").strip() or catalog
|
||||
if catalog not in CATALOG:
|
||||
CONFIG_FIELDS = (
|
||||
ConfigField("catalog", "Katalog", required=True, default="alpha", help="Name des Beispielkatalogs."),
|
||||
)
|
||||
|
||||
|
||||
def normalize_config(settings: dict, secret: str) -> dict:
|
||||
del secret
|
||||
if settings["catalog"] not in CATALOG:
|
||||
raise unprocessable("Der Katalog dieser Beispielquelle ist unbekannt.")
|
||||
return name, {"catalog": catalog}, ""
|
||||
return settings
|
||||
|
||||
|
||||
def probe(row) -> dict:
|
||||
@@ -109,7 +112,8 @@ def install_sample_source() -> None:
|
||||
label="Beispielquelle",
|
||||
representation="text",
|
||||
capabilities=CAPABILITIES,
|
||||
parse_config=parse_config,
|
||||
config_fields=CONFIG_FIELDS,
|
||||
normalize_config=normalize_config,
|
||||
probe=probe,
|
||||
find=find,
|
||||
open_original=open_original,
|
||||
|
||||
Reference in new issue
Block a user