docs: add rel-003, rel-004 releases and update CLI user scoping implementation
Release: REL-003_20260512 — CLI user scoping and local DB ops runbook Requirements & Batches: - BAT-003 (REQ-013): portfolio list --user required enforcement with owner filtering - BAT-004 (REQ-014): portfolio create --user required enforcement with owner assignment - BAT-007 (REQ-001/002/003): local DB validation runbook and baseline docs update CLI Enhancements: - Update user.py: add username-based user lookup (get_by_username) - Add UserDetailResponse schema with service token listing - Update list_service_tokens API in user_service.py - Enhance user detail display with service token information - Add service_token_count and service_token_names to user responses Testing: - Add comprehensive test coverage in test_cli.py for user commands - Validate username-based lookup functionality Release: REL-004_20260512 — Portfolio UUID migration and API UUID switch Requirements & Batches: - BAT-006 (REQ-016/017/018): portfolio UUID migration complete - BAT-008 (REQ-019): baseline documentation update for UUID migration Breaking Changes (REL-003): - portfolio list requires --user <username> parameter - portfolio create requires --user <username> parameter Documentation: - Create rel-003 and rel-004 release documents with rollout and rollback plans - Update docs/releases/index.md with new releases - Update README.md with CLI user scoping clarification - Sync all release verification checklists and deployment notes
This commit is contained in:
@@ -6,7 +6,7 @@ import typer
|
||||
|
||||
from app.cli.core.utils import execute_command, render_output
|
||||
from app.cli.commands.portfolio import _confirm
|
||||
from app.schemas.user import CreateUserRequest, UpdateUserRequest, UserResponse
|
||||
from app.schemas.user import CreateUserRequest, UpdateUserRequest, UserDetailResponse, UserResponse
|
||||
from app.services.user_service import UserService
|
||||
|
||||
|
||||
@@ -37,6 +37,21 @@ def _to_user_response(user) -> UserResponse:
|
||||
)
|
||||
|
||||
|
||||
def _to_user_detail_response(user, service_token_names: list[str]) -> UserDetailResponse:
|
||||
return UserDetailResponse(
|
||||
id=user.id,
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
permission=user.permission,
|
||||
is_active=user.is_active,
|
||||
created_at=user.created_at,
|
||||
updated_at=user.updated_at,
|
||||
last_login_at=user.last_login_at,
|
||||
service_token_count=len(service_token_names),
|
||||
service_token_names=service_token_names,
|
||||
)
|
||||
|
||||
|
||||
@user_app.command("list")
|
||||
def list_users(ctx: typer.Context) -> None:
|
||||
users = _with_service(ctx, lambda service, app_context: [_to_user_response(user) for user in service.list()])
|
||||
@@ -46,9 +61,17 @@ def list_users(ctx: typer.Context) -> None:
|
||||
@user_app.command("get")
|
||||
def get_user(
|
||||
ctx: typer.Context,
|
||||
user_id: str = typer.Argument(..., help="User identifier."),
|
||||
username: str = typer.Argument(..., help="Username."),
|
||||
) -> None:
|
||||
user = _with_service(ctx, lambda service, app_context: _to_user_response(service.get(user_id)))
|
||||
def _get(service: UserService, app_context) -> UserDetailResponse:
|
||||
user = service.get_by_username(username)
|
||||
service_token_names = sorted(token.name for token in service.list_service_tokens(user.id))
|
||||
return _to_user_detail_response(user, service_token_names)
|
||||
|
||||
user = _with_service(
|
||||
ctx,
|
||||
_get,
|
||||
)
|
||||
render_output(ctx.obj.console, ctx.obj.output_format, user)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user