From cb51f42ca77d4c99afe6f4c0ccf883d9912ddda6 Mon Sep 17 00:00:00 2001 From: iltenahmet Date: Sat, 2 Mar 2024 16:29:38 -0500 Subject: [PATCH 1/2] Fix apostrophe issue --- app.py | 7 +++++-- templates/card.html | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index c0e0793..b4debdf 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ from authentication import * from db import * import random +import json app = Flask(__name__) login_manager.init_app(app) @@ -55,8 +56,9 @@ def displayDeck(username, deckTitle): currentDeck = db.decks.find_one({"title": deckTitle}) cardList = currentDeck['cards'] # shuffle deck + print(type(cardList)) random.shuffle(cardList) - return render_template('card.html', deckTitle=deckTitle, username=username, cardList=cardList, isAuth=False) + return render_template('card.html', deckTitle=deckTitle, username=username, cardList=json.dumps(cardList), isAuth=False) else: # authenticate user if (not current_user.is_authenticated or current_user.id != username): @@ -70,9 +72,10 @@ def displayDeck(username, deckTitle): if not currentDeck: currentDeck = db.decks.find_one({"title": deckTitle}) cardList = currentDeck['cards'] + print(type(cardList)) # shuffle deck random.shuffle(cardList) - return render_template('card.html', deckTitle=deckTitle, username=username, cardList=cardList, isAuth=True) + return render_template('card.html', deckTitle=deckTitle, username=username, cardList=json.dumps(cardList), isAuth=True) # TODO: change createDeck to addDeck for naming consistency @app.route("//create", methods=["POST"]) diff --git a/templates/card.html b/templates/card.html index 43ecf9c..b867925 100644 --- a/templates/card.html +++ b/templates/card.html @@ -50,7 +50,8 @@

START

var cardIndex = -1; var questions = '{{ cardList }}' - questions = questions.replaceAll("'","\"") + questions = questions.replaceAll("'","'") + questions = questions.replaceAll(""","\"") questions = questions.replaceAll("\r","") questions = questions.replaceAll("\n","") From a829572041f8b2fbc47d570dca954767ae1a212a Mon Sep 17 00:00:00 2001 From: iltenahmet Date: Sat, 2 Mar 2024 16:31:13 -0500 Subject: [PATCH 2/2] remove debug statements --- app.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/app.py b/app.py index b4debdf..6f3e735 100644 --- a/app.py +++ b/app.py @@ -56,7 +56,6 @@ def displayDeck(username, deckTitle): currentDeck = db.decks.find_one({"title": deckTitle}) cardList = currentDeck['cards'] # shuffle deck - print(type(cardList)) random.shuffle(cardList) return render_template('card.html', deckTitle=deckTitle, username=username, cardList=json.dumps(cardList), isAuth=False) else: @@ -72,7 +71,6 @@ def displayDeck(username, deckTitle): if not currentDeck: currentDeck = db.decks.find_one({"title": deckTitle}) cardList = currentDeck['cards'] - print(type(cardList)) # shuffle deck random.shuffle(cardList) return render_template('card.html', deckTitle=deckTitle, username=username, cardList=json.dumps(cardList), isAuth=True)