inventorymgr/service/users.py
def update_session_user(user_id: int, user_obj: api.UpdatedUser) -> User:
    """Special case for updating the current session user."""
    if user_obj.id != user_id:
        raise api.APIError(reason="incorrect_id", status_code=400)

    user = User.query.get(user_obj.id)
    if user is None:
        raise api.APIError(reason="no_such_user", status_code=400)

    if user.edit_qualifications:
        update_user_qualifications(user, user_obj)
    elif wants_to_update_qualifications(user, user_obj):
        raise insufficient_permissions()

    if user.update_users:
        update_user_permissions(user, user_obj)
    elif wants_to_update_permissions(user, user_obj):
        raise insufficient_permissions()

    update_user_username(user, user_obj)
    update_user_password(user, user_obj)

    db.session.commit()

    return cast(User, user)
Special case for updating the current session user.
Special case for updating the current session user.
Special case for updating the current session user .
def update_session_user(user_id: int, user_obj: api.UpdatedUser) -> User:
    if user_obj.id != user_id:
        raise api.APIError(reason="incorrect_id", status_code=400)
    user = User.query.get(user_obj.id)
    if user is None:
        raise api.APIError(reason="no_such_user", status_code=400)
    if user.edit_qualifications:
        update_user_qualifications(user, user_obj)
    elif wants_to_update_qualifications(user, user_obj):
        raise insufficient_permissions()
    if user.update_users:
        update_user_permissions(user, user_obj)
    elif wants_to_update_permissions(user, user_obj):
        raise insufficient_permissions()
    update_user_username(user, user_obj)
    update_user_password(user, user_obj)
    db.session.commit()
    return cast(User, user)
def update_session_user ( user_id : int , user_obj : api . UpdatedUser ) -> User : if user_obj . id != user_id : raise api . APIError ( reason = "incorrect_id" , status_code = 400 ) user = User . query . get ( user_obj . id ) if user is None : raise api . APIError ( reason = "no_such_user" , status_code = 400 ) if user . edit_qualifications : update_user_qualifications ( user , user_obj ) elif wants_to_update_qualifications ( user , user_obj ) : raise insufficient_permissions ( ) if user . update_users : update_user_permissions ( user , user_obj ) elif wants_to_update_permissions ( user , user_obj ) : raise insufficient_permissions ( ) update_user_username ( user , user_obj ) update_user_password ( user , user_obj ) db . session . commit ( ) return cast ( User , user )
Special case for updating the current session user.
Special case for updating the current session user .
"""Special case for updating the current session user."""
user_id
int
user_obj
api.UpdatedUser