added new/continue session logic
parent
8d35158fc7
commit
4ea8f1ef8e
13
menu.py
13
menu.py
|
@ -12,6 +12,7 @@ bp = Blueprint('menu', __name__, url_prefix='/menu')
|
|||
|
||||
@bp.route("/", methods=("GET", "POST"))
|
||||
def index():
|
||||
deck_status = []
|
||||
dbsession = get_session()
|
||||
if 'user_id' not in session:
|
||||
return login()
|
||||
|
@ -19,15 +20,21 @@ def index():
|
|||
if 'user_id' in session:
|
||||
user_id = session['user_id']
|
||||
username = session['username']
|
||||
|
||||
print(username)
|
||||
|
||||
old_deck = dbsession.query(Deck).filter(Deck.completed == 0, Deck.owner_id == user_id).all()
|
||||
if old_deck != []:
|
||||
deck_status = "old"
|
||||
|
||||
if request.method == "POST":
|
||||
action = request.form.get("menu", False) #internetna rešitev, nevem kako, ampak dela, tj. dobi info iz meni buttonov
|
||||
print(action)
|
||||
if action == "new_session":
|
||||
# @TODO tu bi moral preveriti če je kak unfinished deck, potem bi pisalo continiue, namesto new
|
||||
|
||||
old_deck = dbsession.query(Deck).filter(Deck.completed == 0, Deck.owner_id == user_id).all()
|
||||
if old_deck != []:
|
||||
return redirect(url_for("deck"))
|
||||
|
||||
#preverimo če so sploh karte v collectionu
|
||||
print("userID", user_id)
|
||||
c = dbsession.query(Card).filter(Card.owner_id == user_id).all()
|
||||
|
@ -65,4 +72,4 @@ def index():
|
|||
pass
|
||||
|
||||
|
||||
return render_template("menu/menu.html", username=username)
|
||||
return render_template("menu/menu.html", username=username, deck_status=deck_status)
|
||||
|
|
Loading…
Reference in New Issue