Add is_default flag for system trees
- Add is_default column to trees table - Default trees have no author and are visible to all users - Only admins can create default trees - Update seed script to mark seeded trees as default - Update seed script to use CLI auth instead of creating seed user Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,13 +120,17 @@ async def create_tree(
|
||||
current_user: Annotated[User, Depends(require_engineer_or_admin)]
|
||||
):
|
||||
"""Create a new tree (engineers and admins only)."""
|
||||
# Only admins can create default/system trees
|
||||
is_default = tree_data.is_default and current_user.role == "admin"
|
||||
|
||||
new_tree = Tree(
|
||||
name=tree_data.name,
|
||||
description=tree_data.description,
|
||||
category=tree_data.category,
|
||||
tree_structure=tree_data.tree_structure,
|
||||
author_id=current_user.id,
|
||||
team_id=current_user.team_id
|
||||
author_id=None if is_default else current_user.id, # Default trees have no author
|
||||
team_id=None if is_default else current_user.team_id,
|
||||
is_default=is_default
|
||||
)
|
||||
db.add(new_tree)
|
||||
await db.commit()
|
||||
|
||||
Reference in New Issue
Block a user