a 0-card deck error fixed

master
Kostanjevec 2022-06-23 22:23:39 +02:00
parent c9dacc978e
commit a9de33dfb8
1 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from flask import (
Blueprint, redirect, render_template, request, session, url_for
Blueprint, flash, redirect, render_template, request, session, url_for
)
from config import CONFIG
@ -48,10 +48,11 @@ def index():
#ustvari novi vnos v Deck
user_settings = get_settings(user_id)
deck = probabilistic_deck_generator(user_id, int(user_settings['max_new']), int(user_settings['max_due']))
cards_by_id = get_deck(deck)
if cards_by_id == None:
print("Deck is none")
return render_template(index())
if cards_by_id == "":
flash("Error: Attempted to make deck with 0 cards. Maybe check settings :)")
return render_template("menu/menu.html")
else:
number_of_cards = len(cards_by_id.split(","))