Skip to content

Commit

Permalink
post deleting bug fixed
Browse files Browse the repository at this point in the history
'sqlite3.OperationalError: database is locked' bug fixed on dashboard
  • Loading branch information
DogukanUrker committed Jan 17, 2024
1 parent ebfcf22 commit fed2451
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions routes/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ def dashboard(userName):
case True:
match session["userName"].lower() == userName.lower():
case True:
if request.method == "POST":
if "postDeleteButton" in request.form:
deletePost(request.form["postID"])
return (
redirect(
url_for("dashboard.dashboard", userName=userName)
),
301,
)
connection = sqlite3.connect(DB_POSTS_ROOT)
cursor = connection.cursor()
cursor.execute(
Expand All @@ -35,16 +44,6 @@ def dashboard(userName):
"""select * from comments where lower(user) = ? """,
[(userName.lower())],
)
if request.method == "POST":
if "postDeleteButton" in request.form:
postID = request.form["postID"]
deletePost(postID)
return (
redirect(
url_for("dashboard.dashboard", userName=userName)
),
301,
)
comments = cursor.fetchall()
if posts:
showPosts = True
Expand Down

0 comments on commit fed2451

Please sign in to comment.