diff --git a/gestao/web/api/user/enums.py b/gestao/web/api/user/enums.py index 430ded0..6d60828 100644 --- a/gestao/web/api/user/enums.py +++ b/gestao/web/api/user/enums.py @@ -4,3 +4,4 @@ class UserStatus(str, Enum): active = "active" inactive = "inactive" + analyzing = "analyzing" diff --git a/gestao/web/api/user/views.py b/gestao/web/api/user/views.py index a130a89..a04f36a 100644 --- a/gestao/web/api/user/views.py +++ b/gestao/web/api/user/views.py @@ -46,7 +46,7 @@ async def create_user(create_user: CreateUserDTO) -> User: dependents = create_user_dict.pop("dependents", []) user_id = str(uuid4()) await User.objects.create( - id=user_id, **create_user_dict, status=UserStatus.active + id=user_id, **create_user_dict, status=UserStatus.analyzing ) if dependents: await Dependent.objects.bulk_create( @@ -108,3 +108,17 @@ async def disable_user(user_id: str) -> None: status_code=404, detail="User not found", ) + + +@router.patch("/{user_id}/enable") +async def enable_user(user_id: str) -> None: + try: + user = await User.objects.get(id=user_id) + await user.update(status=UserStatus.active) + return {"detail": "User enable successfully"} + except Exception: + logging.error("User not found", exc_info=True) + raise HTTPException( + status_code=404, + detail="User not found", + )