feat: suppression définitive des mails terminés dans À suivre (par mail ou par catégorie)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGaEeUbVSdKNfpFRgWfCXa
This commit is contained in:
Claude committed 2026-11-20 00:04:15 +01:00
1 parent a4e7ed1f00
commit ea7846ba1c
7 files changed
+66 -3

No files matched your search

+18
View File
@@ -127,3 +127,21 @@ def changer_statut(ids: List[str], statut: str, db_path: Optional[str] = None) -
return touches
finally:
conn.close()
def supprimer(ids: List[str], db_path: Optional[str] = None) -> List[str]:
"""Efface définitivement de l’historique des mails déjà retirés (statut « termine »).
Un mail encore actif n’est jamais supprimé ici : il faut d’abord le retirer. Le mail lui-même (O365, miroir) n’est pas touché."""
ids = list(dict.fromkeys(i for i in ids if i))[:MAX_IDS]
conn = get_connection(db_path)
try:
_pret(conn)
effaces: List[str] = []
with conn:
for i in ids:
cur = conn.execute("DELETE FROM a_suivre WHERE message_id = ? AND statut = 'termine'", (i,))
if cur.rowcount:
effaces.append(i)
return effaces
finally:
conn.close()
+6
View File
@@ -524,6 +524,12 @@ def retirer_a_suivre(r: SuivreIds):
return {"ids": asuivre.changer_statut(_ids_valides(r.ids), "termine")}
@api.post("/a-suivre/supprimer")
def supprimer_a_suivre(r: SuivreIds):
"""Efface de l'historique des mails déjà terminés (ajout par erreur, nettoyage). Les mails actifs sont ignorés ; O365 n'est jamais modifié."""
return {"ids": asuivre.supprimer(_ids_valides(r.ids))}
@api.post("/a-suivre/remettre")
def remettre_a_suivre(r: SuivreIds):
"""Remet au suivi des mails retirés (annulation ou retour depuis les terminés) en gardant leur date de marquage."""
+3
View File
@@ -342,3 +342,6 @@ h1, h2, h3, p { margin: 0; }
.ligne > .m-corps { grid-column: 2; grid-row: 1 / span 2; }
.ligne > .sel { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
}
/* Suppression définitive dans « Terminés » : rouge discret, en contour */
.btn-petit.btn-danger, .btn-ligne.btn-danger { background: transparent; color: var(--ny-erreur); border: 1px solid var(--ny-erreur); }
.btn-petit.btn-danger:hover, .btn-ligne.btn-danger:hover { background: var(--ny-erreur); color: var(--ny-encre-inverse); }
+14 -1
View File
@@ -837,6 +837,12 @@
return chargerASuivre(true);
}).catch(function (e) { if (e.message !== 'session') flash('L\'opération n\'a pas pu être enregistrée. Réessayez.'); });
}
function supprimerDefinitivement(ids, texte) {
return api('/a-suivre/supprimer', { method: 'POST', body: { ids: ids } }).then(function () {
flash(texte); annoncer(texte);
return chargerASuivre(true);
}).catch(function (e) { if (e.message !== 'session') flash('La suppression n\'a pas pu être enregistrée. Réessayez.'); });
}
function annulerRetrait() {
var V = S.asuivre, a = V.annuler;
if (!a) return;
@@ -899,6 +905,12 @@
if (actif) retirerDuSuivi(ids, liste.length + (liste.length > 1 ? ' mails retirés' : ' mail retiré') + ' de « ' + cat + ' ».');
else remettreAuSuivi(ids, liste.length + (liste.length > 1 ? ' mails remis' : ' mail remis') + ' dans « À suivre ».');
} }, txtTout));
if (!actif) {
entete.appendChild(h('button', { type: 'button', class: 'btn-ligne btn-danger', 'aria-label': 'Tout supprimer définitivement : ' + cat + ', ' + nb, onclick: function () {
if (!window.confirm('Supprimer définitivement ' + (liste.length > 1 ? 'ces ' + liste.length + ' mails' : 'ce mail') + ' de l\'historique « ' + cat + ' » ?\nLes mails eux-mêmes ne sont pas touchés.')) return;
supprimerDefinitivement(ids, liste.length + (liste.length > 1 ? ' mails supprimés' : ' mail supprimé') + ' de l\'historique.');
} }, 'Tout supprimer'));
}
var corps = h('div', { role: 'list' });
liste.forEach(function (it) {
var exp = nomExp(it.expediteur), objet = it.objet || '(sans objet)';
@@ -912,7 +924,8 @@
h('button', { type: 'button', class: 'btn-petit', 'aria-label': 'Lire le mail : ' + objet, onclick: function () { lireMail(mm); } }, 'Lire le mail'),
actif
? h('button', { type: 'button', class: 'btn-petit', 'aria-label': 'Retirer de la liste : ' + objet, onclick: function () { retirerDuSuivi([it.message_id], 'Mail retiré : ' + objet); } }, 'Retirer')
: h('button', { type: 'button', class: 'btn-petit', 'aria-label': 'Remettre dans la liste : ' + objet, onclick: function () { remettreAuSuivi([it.message_id], 'Remis dans « À suivre ».'); } }, 'Remettre'))));
: h('button', { type: 'button', class: 'btn-petit', 'aria-label': 'Remettre dans la liste : ' + objet, onclick: function () { remettreAuSuivi([it.message_id], 'Remis dans « À suivre ».'); } }, 'Remettre'),
actif ? null : h('button', { type: 'button', class: 'btn-petit btn-danger', 'aria-label': 'Supprimer définitivement : ' + objet, onclick: function () { supprimerDefinitivement([it.message_id], 'Mail supprimé de l\'historique.'); } }, 'Supprimer'))));
});
var carte = h('section', { class: 'carte groupe-suivi t' + k, 'aria-label': cat });
carte.appendChild(entete); carte.appendChild(corps); frag.appendChild(carte);
+2 -2
View File
@@ -10,7 +10,7 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="/static/fonts.css">
<link rel="stylesheet" href="/static/nyora.css">
<link rel="stylesheet" href="/static/app.css?v=20261119a">
<link rel="stylesheet" href="/static/app.css?v=20261120a">
</head>
<body>
<div id="app" class="coque">
@@ -20,6 +20,6 @@
</div>
<div id="calque"></div>
<div id="annonce" class="sr" role="status" aria-live="polite"></div>
<script src="/static/app.js?v=20261119a"></script>
<script src="/static/app.js?v=20261120a"></script>
</body>
</html>