Added ability to rename location

This commit is contained in:
Donkie
2024-11-20 21:00:39 +01:00
parent 5861190821
commit 37b6d1fcee
5 changed files with 103 additions and 5 deletions

View File

@@ -462,3 +462,15 @@ async def reset_initial_weight(db: AsyncSession, spool_id: int, weight: float) -
await db.commit()
await spool_changed(spool, EventType.UPDATED)
return spool
async def rename_location(
*,
db: AsyncSession,
current_name: str,
new_name: str,
) -> None:
"""Rename all spools with the current location name to the new name."""
await db.execute(
sqlalchemy.update(models.Spool).where(models.Spool.location == current_name).values(location=new_name),
)