Filtere Paperless-Dokumente nach Zusatzfeldern und öffne die Auswahl als großen Dialog mit Filtern links und Treffern rechts.
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 5m37s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 22s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
StommerandClaude Sonnet 5.5 committed 2026-10-24 21:23:29 +02:00
1 parent 9089d830b3
commit f580fb282d
11 files changed
+386 -13

No files matched your search

+85
View File
@@ -535,6 +535,91 @@ def test_paperless_default_search_reads_title_and_content_and_shows_a_preview(cl
)
def test_paperless_custom_field_filters_use_the_instance_fields(client, db, monkeypatch):
import json
import app.sources as sources
calls = []
def fake_get(base, token, path, params):
calls.append({"path": path, "params": dict(params)})
if path == "/api/custom_fields/":
return {
"results": [
{"id": 1, "name": "Rechnungsbetrag", "data_type": "monetary"},
{"id": 2, "name": "bezahlt_am", "data_type": "date"},
{
"id": 3,
"name": "Status",
"data_type": "select",
"extra_data": {"select_options": [{"id": "a", "label": "offen"}, {"id": "b", "label": "bezahlt"}]},
},
{"id": 4, "name": "Verweis", "data_type": "documentlink"},
]
}
if path == "/api/documents/":
return {"count": 0, "results": []}
return {"results": []}
monkeypatch.setattr(sources, "_paperless_get", fake_get)
ada = Actor(client, "ada-custom@example.test", "Ada Custom")
register(db, ada.email, ada.name)
ada.login()
first = ada.request(
"POST",
"/api/v1/connectors",
json={"kind": "paperless", "name": "Archiv", "base_url": "https://paper.example.test", "token": "token-alpha"},
status=201,
)
facets = ada.request("GET", "/api/v1/sources/paperless/facets", params={"connector_id": first["id"]})
assert [item["name"] for item in facets["custom_fields"]] == ["Rechnungsbetrag", "bezahlt_am", "Status"]
assert facets["custom_fields"][2]["options"] == [{"id": "a", "name": "offen"}, {"id": "b", "name": "bezahlt"}]
def ask(rows, status=200):
return ada.request(
"GET",
"/api/v1/sources/paperless/documents",
params={"connector_id": first["id"], "custom": json.dumps(rows)},
status=status,
)
ask([{"field": "2", "op": "range", "value": ["2024-01-01", "2024-06-30"]}])
sent = [call for call in calls if call["path"] == "/api/documents/"][-1]["params"]
assert json.loads(sent["custom_field_query"]) == ["bezahlt_am", "range", ["2024-01-01", "2024-06-30"]]
ask(
[
{"field": "1", "op": "gte", "value": "100,5"},
{"field": "3", "op": "exact", "value": "a"},
{"field": "2", "op": "exists", "value": False},
]
)
sent = [call for call in calls if call["path"] == "/api/documents/"][-1]["params"]
assert json.loads(sent["custom_field_query"]) == [
"AND",
[["Rechnungsbetrag", "gte", 100.5], ["Status", "exact", "a"], ["bezahlt_am", "exists", False]],
]
ask([], 200)
assert "custom_field_query" not in [call for call in calls if call["path"] == "/api/documents/"][-1]["params"]
for rows in (
[{"field": "9", "op": "exact", "value": "x"}],
[{"field": "4", "op": "contains", "value": "1"}],
[{"field": "2", "op": "icontains", "value": "2024"}],
[{"field": "3", "op": "exact", "value": "z"}],
[{"field": "1", "op": "gt", "value": "viel"}],
[{"field": "2", "op": "range", "value": ["2024-06-30", "2024-01-01"]}],
[{"field": "2", "op": "exists", "value": "ja"}],
[{"field": "1", "op": "exact", "value": "1"}] * 6,
):
ask(rows, 422)
ada.request(
"GET",
"/api/v1/sources/paperless/documents",
params={"connector_id": first["id"], "custom": "kein json"},
status=422,
)
def test_paperless_thumbnail_is_bound_to_the_owners_instance(client, db, monkeypatch):
import app.sources as sources