From a9de33dfb8a5f2575c5d6582215be2771daad9b7 Mon Sep 17 00:00:00 2001 From: Kostanjevec Date: Thu, 23 Jun 2022 22:23:39 +0200 Subject: [PATCH] a 0-card deck error fixed --- menu.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/menu.py b/menu.py index 3904bc7..e54249c 100644 --- a/menu.py +++ b/menu.py @@ -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(","))