mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: chapter deletion bug
This commit is contained in:
parent
0f6b3c0000
commit
5056f53c32
1 changed files with 6 additions and 6 deletions
|
|
@ -195,15 +195,15 @@ async def delete_chapter(
|
|||
# RBAC check
|
||||
await rbac_check(request, chapter.chapter_uuid, current_user, "delete", db_session)
|
||||
|
||||
db_session.delete(chapter)
|
||||
db_session.commit()
|
||||
|
||||
# Remove all linked activities
|
||||
statement = select(ChapterActivity).where(ChapterActivity.id == chapter.id)
|
||||
# Remove all linked chapter activities
|
||||
statement = select(ChapterActivity).where(ChapterActivity.chapter_id == chapter.id)
|
||||
chapter_activities = db_session.exec(statement).all()
|
||||
|
||||
for chapter_activity in chapter_activities:
|
||||
db_session.delete(chapter_activity)
|
||||
|
||||
# Delete the chapter
|
||||
db_session.delete(chapter)
|
||||
db_session.commit()
|
||||
|
||||
return {"detail": "chapter deleted"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue