Skip to content

Commit

Permalink
better user, comment, post deleted flash messages
Browse files Browse the repository at this point in the history
  • Loading branch information
DogukanUrker committed Jan 17, 2024
1 parent 18ab2b3 commit cea0e2d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
4 changes: 4 additions & 0 deletions delete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from helpers import (
flash,
sqlite3,
message,
session,
Expand Down Expand Up @@ -39,6 +40,7 @@ def deletePost(postID):
[(commentCount)],
)
connection.commit()
flash("post deleted", "error")
message("2", f'POST: "{postID}" DELETED')


Expand All @@ -60,6 +62,7 @@ def deleteUser(userName):
)
cursor.execute("update sqlite_sequence set seq = seq-1")
connection.commit()
flash(f"user: {userName} deleted", "error")
message("2", f'USER: "{userName}" DELETED')
match perpetrator[0] == "admin":
case True:
Expand All @@ -82,4 +85,5 @@ def deleteComment(commentID):
)
cursor.execute("update sqlite_sequence set seq = seq-1")
connection.commit()
flash("comment deleted", "error")
message("2", f'COMMENT: "{commentID}" DELETED')
2 changes: 0 additions & 2 deletions routes/adminPanelPosts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from helpers import (
flash,
sqlite3,
session,
request,
Expand Down Expand Up @@ -29,7 +28,6 @@ def adminPanelPosts():
if request.method == "POST":
if "postDeleteButton" in request.form:
deletePost(request.form["postID"])
flash("post deleted", "error")
match role == "admin":
case True:
connection = sqlite3.connect(DB_POSTS_ROOT)
Expand Down
1 change: 0 additions & 1 deletion routes/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def dashboard(userName):
if request.method == "POST":
if "postDeleteButton" in request.form:
deletePost(request.form["postID"])
flash("post deleted", "error")
return (
redirect(
url_for("dashboard.dashboard", userName=userName)
Expand Down
1 change: 0 additions & 1 deletion routes/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def post(postID):
if request.method == "POST":
if "postDeleteButton" in request.form:
deletePost(postID)
flash("post deleted", "error")
return redirect(f"/")
elif "commentDeleteButton" in request.form:
deleteComment(request.form["commentID"])
Expand Down

0 comments on commit cea0e2d

Please sign in to comment.