Add inline block editing to schedule templates

- Backend: PATCH /api/schedules/{template_id}/blocks/{block_id} endpoint
- Frontend: Edit button on each block row expands an inline form
  pre-filled with current subject, times, and label; saves via PATCH

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 10:15:19 -08:00
parent 3e7ff2a50b
commit a019e2dda5
3 changed files with 90 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ from app.schemas.schedule import (
ScheduleTemplateOut,
ScheduleTemplateUpdate,
ScheduleBlockCreate,
ScheduleBlockUpdate,
ScheduleBlockOut,
)
@@ -144,6 +145,34 @@ async def add_block(
return block
@router.patch("/{template_id}/blocks/{block_id}", response_model=ScheduleBlockOut)
async def update_block(
template_id: int,
block_id: int,
body: ScheduleBlockUpdate,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
):
result = await db.execute(
select(ScheduleBlock)
.join(ScheduleTemplate)
.where(
ScheduleBlock.id == block_id,
ScheduleBlock.template_id == template_id,
ScheduleTemplate.user_id == current_user.id,
)
)
block = result.scalar_one_or_none()
if not block:
raise HTTPException(status_code=404, detail="Block not found")
for field, value in body.model_dump(exclude_unset=True).items():
setattr(block, field, value)
await db.commit()
await db.refresh(block)
return block
@router.delete("/{template_id}/blocks/{block_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_block(
template_id: int,