Adding fits
This commit is contained in:
1 parent
8185f1f8b3
commit
ab39191af5
19 files changed
+1253
-1
No files matched your search
@@ -0,0 +1,17 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.fit import Fit, FitNote
|
||||
from app.models.user import User
|
||||
|
||||
|
||||
async def create(db: AsyncSession, *, fit: Fit, author: User, body: str) -> FitNote:
|
||||
note = FitNote(
|
||||
fit_id=fit.id,
|
||||
user_id=author.id,
|
||||
username=author.full_name or author.email,
|
||||
body=body,
|
||||
)
|
||||
db.add(note)
|
||||
await db.commit()
|
||||
await db.refresh(note)
|
||||
return note
|
||||
Reference in new issue
Block a user