try to catch edgecase bugs...
parent
edf0dd1ffa
commit
36caf80a34
18
menu.py
18
menu.py
|
@ -5,9 +5,10 @@ from sqlalchemy import create_engine
|
|||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from config import CONFIG
|
||||
from create_db import Deck
|
||||
from create_db import Deck, Card
|
||||
|
||||
from deck import get_deck, probabilistic_deck_generator
|
||||
from auth import login
|
||||
|
||||
bp = Blueprint('menu', __name__, url_prefix='/menu')
|
||||
|
||||
|
@ -17,6 +18,9 @@ dbsession = dbsessionmaker()
|
|||
|
||||
@bp.route("/", methods=("GET", "POST"))
|
||||
def index():
|
||||
if 'user_id' not in session:
|
||||
return login()
|
||||
|
||||
if 'user_id' in session:
|
||||
user_id = session['user_id']
|
||||
username = session['username']
|
||||
|
@ -29,9 +33,19 @@ def index():
|
|||
if action == "new_session":
|
||||
# @TODO tu bi moral preveriti če je kak unfinished deck, potem bi pisalo continiue, namesto new
|
||||
|
||||
#preverimo če so sploh karte v collectionu
|
||||
c = dbsession.query(Card).filter(Card.owner_id == user_id).all()
|
||||
if c == []:
|
||||
print("ne najdem collectiona")
|
||||
return render_template("error/no_cards_in_collection.html")
|
||||
|
||||
#ustvari novi vnos v Deck
|
||||
deck = probabilistic_deck_generator(user_id, 5, 5)
|
||||
cards_by_id = get_deck(deck)
|
||||
if cards_by_id == None:
|
||||
print("DECK IS NONE")
|
||||
return render_template(index())
|
||||
else:
|
||||
number_of_cards = len(cards_by_id.split(","))
|
||||
|
||||
print(cards_by_id, number_of_cards)
|
||||
|
@ -41,7 +55,7 @@ def index():
|
|||
|
||||
return redirect(url_for("deck"))
|
||||
elif action == "matches":
|
||||
pass
|
||||
return redirect(url_for("matches.index"))
|
||||
elif action == "upload":
|
||||
return redirect(url_for("upload.index"))
|
||||
elif action == "settings":
|
||||
|
|
Loading…
Reference in New Issue