From 8f7f1279370561facf5c5ad82842fd864d027828 Mon Sep 17 00:00:00 2001 From: grgr Date: Mon, 3 Oct 2022 20:27:34 +0200 Subject: [PATCH] add new category --- app.py | 11 +++++++++++ library.db | Bin 16384 -> 16384 bytes templates/create.html | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/app.py b/app.py index a04a5ef..f766e8e 100644 --- a/app.py +++ b/app.py @@ -81,6 +81,17 @@ def create(): content=request.form['content'] cat_title=request.form['cat'] + #create a new category: + new_category = request.form['new_category'] + # if a new category_title is created add it to the table of categories + if cat_title == 'New category' and new_category: + conn.execute('INSERT INTO categories (title) VALUES (?)', + (new_category,)) + conn.commit() + # update cat_title to refer to the newly added category + cat_title = new_category + + if not content: flash('plz write a content!') return redirect(url_for('home')) diff --git a/library.db b/library.db index 590a14daad03b5fe7b7d29afd39acbe355cd8854..1aab9d2fbf8a1c1e108f0006356a93b76f2107f7 100644 GIT binary patch delta 321 zcmZo@U~Fh$oFL68F;T{uRf0j!L}6pf0)7z=zBLT|xB1udH}gC5OY{BayT-R>v!cKh zzIqLARt836Z8jqVBO_fy16>1S1w#ufBQq-#!`#Gzg3P>hg@U5|Gn1r?0>qh;7w7>vbX+L2sal3$RSEX@j( f6~&M>Fb2Dg1t=+vCJAy`N>O4t(4&(V*~b9@EqO`Q delta 125 zcmZo@U~Fh$oFL68G*QNxRfs{)zjkBF0)7EjerX2&+x%Mec zEYD{mvm#@1Vo7Rxeo dF*7d%0|PVvA_o2k{D=7$0nM7iKY5XT901QcAoKtL diff --git a/templates/create.html b/templates/create.html index 0b0c822..a7e0520 100644 --- a/templates/create.html +++ b/templates/create.html @@ -14,6 +14,7 @@
+
+ + +