def update_user_profile_by_model(user: UserModel, display_name: str, new_password: str, api_token: str, image=None, company=None): user.display_name = display_name user.password = new_password user.image = image or user.image user.company = company or user.company user.api_token = api_token user.updated_at = int(time.time()) db.session.commit()
def create_user_by_dict(args): model = UserModel() model.username = args.get('username') model.password = args.get('password') model.role = args.get('role') model.display_name = args.get('display_name') model.company = args.get('company') or '' model.image = args.get('image') or '' model.created_at = int(time.time()) model.updated_at = int(time.time()) db.session.add(model) db.session.flush() inserted_id = model.id db.session.commit() return inserted_id