async def put_user_id( user_in: UserIn_Pydnatic, user_id: int, current_superuser: User = Depends(find_current_superuser), ): update_dict = user_in.dict(exclude_unset=True) del update_dict["categories_ids"] await User.filter(id=user_id).update(**update_dict) user = await User.filter(id=user_id).prefetch_related("creds").first() await user.update_calendar() await user.categories.clear() categories = await Category.filter(id__in=user_in.categories_ids).all() await user.categories.add(*categories) return await User_Pydnatic.from_queryset_single(User.get(id=user_id))
async def get_user_id(user_id: int, current_user: User = Depends(find_current_user)): return await User_Pydnatic.from_queryset_single(User.get(id=user_id))
async def patch_current_user(user_update: NormalUserUpdate, current_user: User = Depends(find_current_user)): await User.get(id=current_user.id ).update(**user_update.dict(exclude_unset=True)) return await User_Pydnatic.from_queryset_single( User.get(id=current_user.id))