예제 #1
0
파일: main.py 프로젝트: Rood1e/Task_tracker
def add_dish():
    if 'username' not in session:
        return redirect('/login')
    form = AddDishForm()
    if form.validate_on_submit():
        title = form.title.data
        content = form.content.data
        dish = DishModel(db.get_connection())
        dish.insert(title,content,session['user_id'])
        return redirect("/index")
    return render_template('add_dish.html', title='Рецепты',
                           form=form, username=session['username'])
예제 #2
0
def index():
    if 'username' not in session:
        return render_template('homepage.html')
    dish = DishModel(db.get_connection()).get_all()
    return render_template('index.html',
                           username=session['username'],
                           dish=dish)
예제 #3
0
파일: main.py 프로젝트: Rood1e/Task_tracker
def delete_dish(dish_id):
    if 'username' not in session:
        return redirect('/login')
    nm = DishModel(db.get_connection())
    nm.delete(dish_id)
    return redirect("/index")
예제 #4
0
파일: main.py 프로젝트: Rood1e/Task_tracker
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import DataRequired

from registerform import RegisterForm
from loginform import LoginForm
from add_dish import AddDishForm
from dishmodel import DishModel
from usersmodel import UsersModel
from db import DB

app = Flask(__name__)
app.config['SECRET_KEY'] = 'yandexlyceum_secret_key'

db = DB()
UsersModel(db.get_connection()).init_table()
DishModel(db.get_connection()).init_table()

@app.route('/')
@app.route('/index')
def index():
    if 'username' not in session:
        return render_template('homepage.html')  
    dish = DishModel(db.get_connection()).get_all()
    return render_template('index.html', username=session['username'], dish = dish)

@app.route('/homepage')
def homepage():
    return render_template('homepage.html')

@app.route('/login', methods=['GET', 'POST'])
def login():