|
|
@ -5,7 +5,7 @@ from itertools import groupby # to handle complex iterations
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
import sqlite3
|
|
|
|
import sqlite3
|
|
|
|
from flask import Flask, render_template, url_for, request, redirect
|
|
|
|
from flask import Flask, render_template, url_for, request, redirect, flash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----- functions ----- #
|
|
|
|
# ----- functions ----- #
|
|
|
@ -72,9 +72,25 @@ def home():
|
|
|
|
def create():
|
|
|
|
def create():
|
|
|
|
conn = get_db_connection()
|
|
|
|
conn = get_db_connection()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
|
|
|
content = request.form['content']
|
|
|
|
|
|
|
|
cat_title = request.form['cat']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not content:
|
|
|
|
|
|
|
|
flash('plz write a content!')
|
|
|
|
|
|
|
|
return redirect(url_for('home'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat_id = conn.execute('SELECT id FROM categories WHERE title = (?);',
|
|
|
|
|
|
|
|
(cat_title,)).fetchone()['id']
|
|
|
|
|
|
|
|
conn.execute('INSERT INTO cards (content, category_id) VALUES (?,?)',
|
|
|
|
|
|
|
|
(content, cat_title))
|
|
|
|
|
|
|
|
conn.commit()
|
|
|
|
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
return redirect(url_for('home'))
|
|
|
|
|
|
|
|
|
|
|
|
categories = conn.execute('SELECT title FROM categories;').fetchall()
|
|
|
|
categories = conn.execute('SELECT title FROM categories;').fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
conn.close()
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
return render_template('create.html', categories=categories)
|
|
|
|
return render_template('create.html', categories=categories)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|