Ordne Akten und Vorgaenge nach fachlichem Datum oder eigener Reihenfolge und mache den Inhalt zur Arbeitsansicht.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
27925093e2
commit
52bda91aad
22 files changed
+2079
-258
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"""Display order for bindings. Stored positions stay intact when sorting by date."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def arrange(items: list[dict], mode: str, direction: str) -> list[dict]:
|
||||
"""Return a new list. Undated entries stay last in both date directions."""
|
||||
if mode == "position":
|
||||
ordered = sorted(items, key=lambda item: (item["_raw_position"], item["id"]))
|
||||
else:
|
||||
dated = [item for item in items if item.get("_document_on")]
|
||||
undated = [item for item in items if not item.get("_document_on")]
|
||||
if direction == "desc":
|
||||
dated.sort(key=lambda item: (item["_raw_position"], item["id"]))
|
||||
dated.sort(key=lambda item: item["_document_on"], reverse=True)
|
||||
else:
|
||||
dated.sort(key=lambda item: (item["_document_on"], item["_raw_position"], item["id"]))
|
||||
undated.sort(key=lambda item: (item["_raw_position"], item["id"]))
|
||||
ordered = dated + undated
|
||||
result = []
|
||||
for index, item in enumerate(ordered):
|
||||
visible = {key: value for key, value in item.items() if not key.startswith("_")}
|
||||
visible["position"] = index
|
||||
result.append(visible)
|
||||
return result
|
||||
Reference in new issue
Block a user