Skip to content

Commit

Permalink
fix: update user status doc
Browse files Browse the repository at this point in the history
  • Loading branch information
erfjab committed Jul 29, 2024
1 parent 48a5ad2 commit 3fb46c1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/db/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,25 @@ def autodelete_expired_users(db: Session,
return expired_users


def update_user_status(db: Session, dbuser: User, status: UserStatus) -> User:
"""
Updates a user's status and records the time of change.
Args:
db (Session): Database session.
dbuser (User): The user to update.
status (UserStatus): The new status.
Returns:
User: The updated user object.
"""
dbuser.status = status
dbuser.last_status_change = datetime.utcnow()
db.commit()
db.refresh(dbuser)
return dbuser


def set_owner(db: Session, dbuser: User, admin: Admin) -> User:
"""
Sets the owner (admin) of a user.
Expand Down

0 comments on commit 3fb46c1

Please sign in to comment.