mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-25 07:08:11 -05:00
* 🌐 Refactor file structure to support internationalization * ✅ Update tests changed after i18n * 🔀 Merge Typer style from master * 🔧 Update MkConfig with Typer-styles * 🎨 Format mkdocs.yml with cannonical form * 🎨 Format mkdocs.yml * 🔧 Update MkDocs config * ➕ Add docs translation scripts dependencies * ✨ Add Typer scripts to handle translations * ✨ Add missing translation snippet to include * ✨ Update contributing docs, add docs for translations * 🙈 Add docs_build to gitignore * 🔧 Update scripts with new locations and docs scripts * 👷 Update docs deploy action with translations * 📝 Add note about languages not supported in the theme * ✨ Add first translation, for Spanish
31 lines
843 B
Python
31 lines
843 B
Python
from . import models, schemas
|
|
|
|
|
|
def get_user(user_id: int):
|
|
return models.User.filter(models.User.id == user_id).first()
|
|
|
|
|
|
def get_user_by_email(email: str):
|
|
return models.User.filter(models.User.email == email).first()
|
|
|
|
|
|
def get_users(skip: int = 0, limit: int = 100):
|
|
return list(models.User.select().offset(skip).limit(limit))
|
|
|
|
|
|
def create_user(user: schemas.UserCreate):
|
|
fake_hashed_password = user.password + "notreallyhashed"
|
|
db_user = models.User(email=user.email, hashed_password=fake_hashed_password)
|
|
db_user.save()
|
|
return db_user
|
|
|
|
|
|
def get_items(skip: int = 0, limit: int = 100):
|
|
return list(models.Item.select().offset(skip).limit(limit))
|
|
|
|
|
|
def create_user_item(item: schemas.ItemCreate, user_id: int):
|
|
db_item = models.Item(**item.dict(), owner_id=user_id)
|
|
db_item.save()
|
|
return db_item
|