diff --git a/app.py b/app.py index fb7f021..5a25882 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ from flask import Flask, render_template, request, redirect, abort, url_for, make_response from authentication import * from db import * +import random app = Flask(__name__) @@ -27,8 +28,31 @@ def signup(): @app.route("//decks") def allDecks(username): # would need to first find user in db, but not set up yet - mainDecks = db.decks.find({}) - return render_template('decks.html', mainDecks=mainDecks) + if username == "guest": + mainDecks = db.decks.find({}) + return render_template('decks.html', mainDecks=mainDecks) + else: + return "to do: for users" + +@app.route("//") +def displayDeck(username, deckTitle): + if username == "guest": + # get the list of cards for the deck + currentDeck = db.decks.find_one({"title": deckTitle}) + cardList = currentDeck['cards'] + # generate a random index to generate a random card + index = random.randint(0, len(cardList)-1) + question = cardList[index] + # remove card to avoid repetition + cardList.pop(index) + + return render_template('card.html', deckTitle=deckTitle, question=question, username=username) + + if 'add-card' in request.form: + return redirect('/username/deckTitle/add') + elif 'edit' in request.form: + return redirect('/username/deckTitle/index/add') + return "temp" @app.route("//create", methods=["POST"]) def createDeck(username): diff --git a/static/css/style.css b/static/css/style.css index 66b2a36..dd60fe1 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -67,17 +67,6 @@ h3 { } -.vertical-alig { - display: flex; - justify-content: space-between; - flex-direction: column; - align-items: center; - margin: auto; - width: 90%; - aspect-ratio: 9 / 5; - -} - .button { width: 100%; height: 25%; diff --git a/templates/card.html b/templates/card.html new file mode 100644 index 0000000..ea2aa3b --- /dev/null +++ b/templates/card.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} + +{% block container %} +

{{ deckTitle }}

+
+

{{ question }}

+
+ +
+ + +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/decks.html b/templates/decks.html index 4eee469..a7732a3 100644 --- a/templates/decks.html +++ b/templates/decks.html @@ -2,13 +2,16 @@ {% block container %} - -
-
- {% for deck in mainDecks %} - - {% endfor %} -
+{% for deck in mainDecks %} + +{% endfor %} + +{% for deck in personalDecks %} + +{% endfor %} {% endblock %} \ No newline at end of file