Merge pull request #10 from psukys/6-tags-saved-for-rejected-items
Fix: on quote deletion - delete all quote's dangling tags
This commit is contained in:
commit
c7e7c5cfe1
1 changed files with 4 additions and 0 deletions
|
@ -131,6 +131,10 @@ def moderate():
|
||||||
|
|
||||||
elif request.form['submit'] == "Delete":
|
elif request.form['submit'] == "Delete":
|
||||||
quote = Quote.query.filter_by(id=request.form['quoteid']).first()
|
quote = Quote.query.filter_by(id=request.form['quoteid']).first()
|
||||||
|
# Delete dangling tags (alive only with current Quote)
|
||||||
|
dangling_tags = [tag for tag in quote.tags if tag.quotes.count() == 1]
|
||||||
|
for tag in dangling_tags:
|
||||||
|
db.session.delete(tag)
|
||||||
db.session.delete(quote)
|
db.session.delete(quote)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue