diff --git a/backend/app/api/endpoints/trees.py b/backend/app/api/endpoints/trees.py index cce1b785..fb63f7e3 100644 --- a/backend/app/api/endpoints/trees.py +++ b/backend/app/api/endpoints/trees.py @@ -629,6 +629,13 @@ async def update_tree( for field, value in update_data.items(): setattr(tree, field, value) + # Keep visibility and is_public in sync + if tree_data.is_public is not None: + if tree_data.is_public and tree.visibility not in ('public',): + tree.visibility = 'public' + elif not tree_data.is_public and tree.visibility == 'public': + tree.visibility = 'team' # downgrade from public to team + # Increment version if tree structure changed if "tree_structure" in update_data: tree.version += 1 @@ -1074,6 +1081,7 @@ async def update_tree_visibility( # Update visibility old_visibility = tree.visibility tree.visibility = visibility_data.visibility + tree.is_public = (visibility_data.visibility == 'public') await log_audit(db, current_user.id, "tree.visibility.update", "tree", tree.id, {"tree_name": tree.name, "old_visibility": old_visibility,