feat(training): delete group button (admin only) on Training page
- Backend DELETE /api/groups/<gid> (admin, own-org enforced via _get_owned_group); cascades removal of the group's sessions. GroupStore.delete added. - Training.vue: each group card gets a trash (Trash2 line icon) delete button shown only to admins (auth.isAdmin); confirm dialog; @click.stop so it doesn't navigate. Card restructured so the delete button is not inside the clickable router-link. - test_user_journey: trainee cannot delete (403), admin deletes, group gone (404). All suites pass. Rebuilt dist.
This commit is contained in:
@@ -324,6 +324,28 @@ def update_persona(gid: str, pid: str):
|
||||
return jsonify({"persona": strip_secret_fields(full)})
|
||||
|
||||
|
||||
@groups_bp.delete("/<gid>")
|
||||
@require_auth
|
||||
@require_roles("admin")
|
||||
def delete_group(gid: str):
|
||||
"""Delete a persona group (admin only, own org)."""
|
||||
s = _stores()
|
||||
group = _get_owned_group(s, gid) # also enforces tenant org (super_admin global)
|
||||
s["groups"].delete(gid)
|
||||
# cascade: also remove finished/active sessions for this group's personas
|
||||
try:
|
||||
sess = s.get("session_store")
|
||||
if sess and hasattr(sess, "sessions"):
|
||||
for r in sess.sessions.all():
|
||||
if r.get("group_id") == gid:
|
||||
key = r.get("id") or r.get("sid")
|
||||
if key:
|
||||
sess.sessions.delete(key)
|
||||
except Exception:
|
||||
pass
|
||||
return jsonify({"ok": True, "deleted": gid})
|
||||
|
||||
|
||||
@groups_bp.post("/<gid>/reanalyze")
|
||||
@require_auth
|
||||
@require_roles("admin")
|
||||
|
||||
Reference in New Issue
Block a user