|
|
@ -109,11 +109,14 @@ def create():
|
|
|
|
(new_topic,))
|
|
|
|
(new_topic,))
|
|
|
|
conn.commit()
|
|
|
|
conn.commit()
|
|
|
|
topic_tag = new_topic
|
|
|
|
topic_tag = new_topic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat_id = conn.execute('SELECT id FROM categories WHERE category_name = (?);',
|
|
|
|
|
|
|
|
(category_name,)).fetchone()['id']
|
|
|
|
|
|
|
|
|
|
|
|
topic_id = conn.execute('SELECT id FROM topics WHERE content = (?);',
|
|
|
|
topic_id = conn.execute('SELECT id FROM topics WHERE content = (?);',
|
|
|
|
(topic_tag,)).fetchone()['id']
|
|
|
|
(topic_tag,)).fetchone()['id']
|
|
|
|
conn.execute('INSERT INTO topic_cards (topic_id, card_id) VALUES (?,?)',
|
|
|
|
conn.execute('INSERT INTO topic_cards (topic_id, card_id) VALUES (?,?)',
|
|
|
|
(topic_id, cat_id))
|
|
|
|
(topic_id, cat_id))
|
|
|
|
|
|
|
|
|
|
|
|
if not content:
|
|
|
|
if not content:
|
|
|
|
flash('plz write a content!')
|
|
|
|
flash('plz write a content!')
|
|
|
@ -121,10 +124,15 @@ def create():
|
|
|
|
|
|
|
|
|
|
|
|
cat_id = conn.execute('SELECT id FROM categories WHERE category_name = (?);',
|
|
|
|
cat_id = conn.execute('SELECT id FROM categories WHERE category_name = (?);',
|
|
|
|
(category_name,)).fetchone()['id']
|
|
|
|
(category_name,)).fetchone()['id']
|
|
|
|
|
|
|
|
|
|
|
|
conn.execute('INSERT INTO cards (content, category_id) VALUES (?,?)',
|
|
|
|
conn.execute('INSERT INTO cards (content, category_id) VALUES (?,?)',
|
|
|
|
(content, cat_id))
|
|
|
|
(content, cat_id))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topic_id = conn.execute('SELECT id FROM topics WHERE content = (?);',
|
|
|
|
|
|
|
|
(topic_tag,)).fetchone()['id']
|
|
|
|
|
|
|
|
conn.execute('INSERT INTO topic_cards (topic_id, card_id) VALUES (?,?)',
|
|
|
|
|
|
|
|
(topic_id, cat_id))
|
|
|
|
|
|
|
|
|
|
|
|
conn.commit()
|
|
|
|
conn.commit()
|
|
|
|
conn.close()
|
|
|
|
conn.close()
|
|
|
|
return redirect(url_for('home'))
|
|
|
|
return redirect(url_for('home'))
|
|
|
@ -147,6 +155,7 @@ def edit(id):
|
|
|
|
|
|
|
|
|
|
|
|
categories = conn.execute(
|
|
|
|
categories = conn.execute(
|
|
|
|
'SELECT category_name FROM categories;').fetchall()
|
|
|
|
'SELECT category_name FROM categories;').fetchall()
|
|
|
|
|
|
|
|
topics = conn.execute('SELECT content FROM topics;').fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
content = request.form['content']
|
|
|
|
content = request.form['content']
|
|
|
|