added new/continue session logic
parent
8d35158fc7
commit
4ea8f1ef8e
11
menu.py
11
menu.py
|
@ -12,6 +12,7 @@ bp = Blueprint('menu', __name__, url_prefix='/menu')
|
||||||
|
|
||||||
@bp.route("/", methods=("GET", "POST"))
|
@bp.route("/", methods=("GET", "POST"))
|
||||||
def index():
|
def index():
|
||||||
|
deck_status = []
|
||||||
dbsession = get_session()
|
dbsession = get_session()
|
||||||
if 'user_id' not in session:
|
if 'user_id' not in session:
|
||||||
return login()
|
return login()
|
||||||
|
@ -19,14 +20,20 @@ def index():
|
||||||
if 'user_id' in session:
|
if 'user_id' in session:
|
||||||
user_id = session['user_id']
|
user_id = session['user_id']
|
||||||
username = session['username']
|
username = session['username']
|
||||||
|
|
||||||
print(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":
|
if request.method == "POST":
|
||||||
action = request.form.get("menu", False) #internetna rešitev, nevem kako, ampak dela, tj. dobi info iz meni buttonov
|
action = request.form.get("menu", False) #internetna rešitev, nevem kako, ampak dela, tj. dobi info iz meni buttonov
|
||||||
print(action)
|
print(action)
|
||||||
if action == "new_session":
|
if action == "new_session":
|
||||||
# @TODO tu bi moral preveriti če je kak unfinished deck, potem bi pisalo continiue, namesto new
|
# @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
|
#preverimo če so sploh karte v collectionu
|
||||||
print("userID", user_id)
|
print("userID", user_id)
|
||||||
|
@ -65,4 +72,4 @@ def index():
|
||||||
pass
|
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