app/modules/users/services.py
def update(self, db: Session, id: int, user: UserUpdate) -> UserResponse:
        """
        Edits an user by id.

        Args:
            db (Session): The database session.
            id (int): The user ID.
            user (UserUpdate): The user update model.

        Returns:
            UserResponse: The User Response model.
        """        
        db_user = db.query(User).filter(and_(
            User.id == id,
            User.is_deleted == False
        )).first()
        if not db_user:
            return None

        if user.password != None:
            db_user.password = user.password
            db_user.hash_password()
            user.password = db_user.password

        db_user.update(db, **user.dict(exclude_unset=True))
        new_user = UserResponse.from_orm(db_user)
        return new_user

        Edits an user by id.

        Args:
            db (Session): The database session.
            id (int): The user ID.
            user (UserUpdate): The user update model.

        Returns:
            UserResponse: The User Response model.
        
Edits an user by id.
Edits an user by id .
def update(self, db: Session, id: int, user: UserUpdate) -> UserResponse:
        db_user = db.query(User).filter(and_(
            User.id == id,
            User.is_deleted == False
        )).first()
        if not db_user:
            return None
        if user.password != None:
            db_user.password = user.password
            db_user.hash_password()
            user.password = db_user.password
        db_user.update(db, **user.dict(exclude_unset=True))
        new_user = UserResponse.from_orm(db_user)
        return new_user
def update ( self , db : Session , id : int , user : UserUpdate ) -> UserResponse : db_user = db . query ( User ) . filter ( and_ ( User . id == id , User . is_deleted == False ) ) . first ( ) if not db_user : return None if user . password != None : db_user . password = user . password db_user . hash_password ( ) user . password = db_user . password db_user . update ( db , ** user . dict ( exclude_unset = True ) ) new_user = UserResponse . from_orm ( db_user ) return new_user
Edits an user by id.
Edits an user by id .
"""
        Edits an user by id.

        Args:
            db (Session): The database session.
            id (int): The user ID.
            user (UserUpdate): The user update model.

        Returns:
            UserResponse: The User Response model.
        """
The User Response model.
The User Response model .
UserResponse
self
db
Session
The database session.
The database session .
id
int
The user ID.
The user ID .
user
UserUpdate
The user update model.
The user update model .