Delete a post. Ensures that the post exists and that the logged in user is the author of the post.
(id)
| 113 | @bp.route(class="st">"/<int:id>/delete", methods=(class="st">"POST",)) |
| 114 | @login_required |
| 115 | def delete(id): |
| 116 | class="st">"""Delete a post. |
| 117 | |
| 118 | Ensures that the post exists and that the logged in user is the |
| 119 | author of the post. |
| 120 | class="st">""" |
| 121 | get_post(id) |
| 122 | db = get_db() |
| 123 | db.execute(class="st">"DELETE FROM post WHERE id = ?", (id,)) |
| 124 | db.commit() |
| 125 | return redirect(url_for(class="st">"blog.index")) |