def register(): form = RegisterForm() if form.validate_on_submit(): name = form.username.data password = form.password.data passwordagain = form.password_again.data email = form.email.data user_type = form.mode.data if password == passwordagain: um = UserModel(db.get_connection()) um.insert(name, password, email, user_type) exi = um.exists(name, password) session['username'] = name session['user_id'] = exi[1] return redirect("/succes_register") else: return redirect("/passw_dont_match") return render_template('register.html', form=form)
from db import DB from user_model import UserModel from news_model import NewsModel from items_model import ItemsModel db = DB() users_model = UserModel(db.get_connection()) users_model.init_table() users_model.insert("test1", "11111111", "*****@*****.**", "admin") users_model.insert("admin", "password11", "*****@*****.**", "admin") news_model = NewsModel(db.get_connection()) news_model.init_table() items_model = ItemsModel(db.get_connection()) items_model.init_table() items_model.insert("Defaul candy", "www.yandex.ru", "30", "Classic candy with honey and cream.", "25")