Skip to content

Commit

Permalink
Merge pull request #46 from software-students-spring2024/more-card-crud
Browse files Browse the repository at this point in the history
More card crud
  • Loading branch information
shriyakalakata authored Feb 26, 2024
2 parents 960e315 + 630a8d4 commit d90f0ae
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ def editCard(username, deckTitle, cardIndex):
# would redirect to template for Cards
return "edited card"

@app.route("/<username>/<deckTitle>/<cardIndex>/delete")
def deleteCard(username, deckTitle, cardIndex):
# would need to first find user in db, but not set up yet
deck = db.decks.find_one({"title": deckTitle})
deck["cards"].pop(int(cardIndex))
db.decks.update_one({"title": deckTitle}, {"$set": deck})
# would redirect to template for Cards
return "deleted card"

@app.route("/<username>/<deckTitle>/delete")
def deleteDeck(username, deckTitle):
# would need to first find user in db, but not set up yet
db.decks.delete_one({"title": deckTitle})
# would redirect to template for Cards
return "deleted deck"

# run the app
if __name__ == "__main__":
FLASK_PORT = os.getenv("FLASK_PORT", "5000")
Expand Down

0 comments on commit d90f0ae

Please sign in to comment.