fix: garde-fou edition base sur label projet au lieu de TYPES_SYSTEME fige
- _est_editable() dans trilium_api.py : editable si label projet ou type=projet - tool_update_note + delete_note_safe utilisent ce critere - tool_get_children : filtre TYPES_SYSTEME retire (transparence) Corrige : composants techniques editables, get_children ne les masque plus. Revele par le test Phase 3 (agent bloque sur edition de composant).
This commit is contained in:
+14
-7
@@ -138,13 +138,8 @@ def delete_note_safe(note_id: str):
|
||||
note = get_note(note_id)
|
||||
if not note:
|
||||
return (False, "Note introuvable")
|
||||
type_val = None
|
||||
for a in note.get("attributes", []):
|
||||
if a.get("type") == "label" and a.get("name") == "type":
|
||||
type_val = a.get("value")
|
||||
break
|
||||
if type_val not in TYPES_SYSTEME:
|
||||
return (False, "Refus : note sans type systeme connu (type=%s)" % type_val)
|
||||
if not _est_editable(note):
|
||||
return (False, "Refus : note structurelle protegee (sans label projet)")
|
||||
titre = note.get("title", "?")
|
||||
ok = _ea().delete_note(note_id)
|
||||
if ok:
|
||||
@@ -214,3 +209,15 @@ def add_relation_safe(source_id, nom, cible_id):
|
||||
except Exception as e:
|
||||
return (False, "Echec creation relation: %s" % e)
|
||||
return (True, "Relation creee: %s ~%s %s" % (source_id, nom, cible_id))
|
||||
|
||||
|
||||
def _est_editable(note):
|
||||
"""Nouveau critere de garde-fou : une note est editable/supprimable si elle
|
||||
porte un label projet (note de projet, propriete du projet), ou si son type
|
||||
est 'projet' lui-meme. Sinon (ontologie, skills universels, dossiers
|
||||
structurels) elle est protegee par defaut. Remplace TYPES_SYSTEME (liste
|
||||
figee, desynchronisee de l ontologie a chaque nouvelle classe)."""
|
||||
labels = {a.get("name"): a.get("value") for a in note.get("attributes", []) if a.get("type") == "label"}
|
||||
if labels.get("type") == "projet":
|
||||
return True
|
||||
return bool(labels.get("projet"))
|
||||
|
||||
Reference in New Issue
Block a user