Skip to content

Commit

Permalink
Merge pull request #11 from fga-eps-mds/improvement/update-status-field
Browse files Browse the repository at this point in the history
add status 'analyzing' and route for enable user
  • Loading branch information
VictorAmaralC authored Nov 24, 2023
2 parents 09f0503 + ce1cee9 commit df82778
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions gestao/web/api/user/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
class UserStatus(str, Enum):
active = "active"
inactive = "inactive"
analyzing = "analyzing"
16 changes: 15 additions & 1 deletion gestao/web/api/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
)

0 comments on commit df82778

Please sign in to comment.