Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tutorial3/website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def delete_post(id):

if not post:
flash("Post does not exist.", category='error')
elif current_user.id != post.id:
elif current_user.id != post.author:
flash('You do not have permission to delete this post.', category='error')
else:
db.session.delete(post)
Expand Down
4 changes: 3 additions & 1 deletion tutorial4/website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ def delete_post(id):

if not post:
flash("Post does not exist.", category='error')
elif current_user.id != post.id:
elif current_user.id != post.author:
flash('You do not have permission to delete this post.', category='error')
else:
for comment in post.comments:
db.session.delete(comment)
db.session.delete(post)
db.session.commit()
flash('Post deleted.', category='success')
Expand Down
4 changes: 3 additions & 1 deletion tutorial5/website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ def delete_post(id):

if not post:
flash("Post does not exist.", category='error')
elif current_user.id != post.id:
elif current_user.id != post.author:
flash('You do not have permission to delete this post.', category='error')
else:
for comment in post.comments:
db.session.delete(comment)
db.session.delete(post)
db.session.commit()
flash('Post deleted.', category='success')
Expand Down