def regisration(): title = "Регистрация в Apotheka" login_form = RegistrationForm(request.form) if request.method == 'POST' and login_form.validate(): user = User(username=login_form.user_name.data, email=login_form.email.data, userTelegrammChat=request.form.get("telegram")) try: user.set_password(login_form.password.data) db.session.add(user) db.session.commit() profile = Profile( user_id=user.id, name=login_form.Name.data, sername=login_form.Sername.data, age=int(login_form.age.data), isWoman=( # Не уверен на счет верности переноса str_to_bool(request.form.get("gender")))) db.session.add(profile) db.session.commit() flash('Спасибо за регистрацию') return redirect(url_for('login')) except IntegrityError: flash('Пользователи с такими данными уже существуют') return redirect(url_for('regisration')) return render_template('/user/registration.html', title=title, form=login_form, User="", Profile="")
def register(): form = RegistrationForm() if request.method == 'POST' and form.validate(): username = form.username.data email = form.email.data password = form.password.data user = User(username, email, password) db.session.add(user) db.session.commit() return redirect(url_for("login")) return render_template("register.html", form=form)