def reqister(): form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.password_again.data: return render_template('register.html', title='Регистрация', form=form, message="Пароли не совпадают") session = create_session() if session.query(User).filter(User.email == form.email.data).first(): return render_template('register.html', title='Регистрация', form=form, message="Такой пользователь уже есть") user = User( surname=form.surname.data, name=form.name.data, age=form.age.data, position=form.position.data, speciality=form.speciality.data, addres=form.addres.data, email=form.email.data, ) pas = form.password.data user.hassed_password = User.set_password(pas) session.add(user) session.commit() return redirect('/login') return render_template('register.html', title='Регистрация', form=form)
def reqister(): form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.password_again.data: return render_template('register.html', title='Регистрация', form=form, message="Пароли не совпадают") session = db_session.create_session() if session.query(User).filter(User.email == form.email.data).first(): return render_template('register.html', title='Регистрация', form=form, message="Такой пользователь уже есть") user = User( name=form.name.data, email=form.email.data, about=form.about.data ) test = User() user.set_password(form.password.data) session.add(user) session.commit() return redirect('/login') return render_template('register.html', title='Регистрация', form=form)
def register(): if current_user.is_authenticated == 1: return unauthorized() form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.password_again.data: return render_template('register.html', title='Регистрация', form=form, message="Пароли не совпадают", users=users) session = db_session.create_session() if session.query(User).filter(User.email == form.email.data).first(): return render_template('register.html', title='Регистрация', form=form, message="Такой пользователь уже есть", users=users) user = User( name=form.name.data, email=form.email.data, about=form.about.data ) user.set_password(form.password.data) session.add(user) session.commit() updateUsers(session) return redirect('/login') return render_template('register.html', title='Регистрация', form=form, users=users)
def reqister(): form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.password_again.data: return render_template('register.html', title='Регистрация', form=form, message="Пароли не совпадают") session = create_session() if session.query(User).filter(User.email == form.email.data).first(): return render_template('register.html', title='Регистрация', form=form, message="Такой пользователь уже есть") user_id = random_id() category_id = random_id() user = User(id=user_id, surname=form.surname.data, name=form.name.data, category=category_id, age=form.age.data, description=form.description.data, email=form.email.data, worker=form.worker.data) UPLOAD_DIR: Path = Path(__file__).parent / 'static/users_img' UPLOAD_DIR.mkdir(parents=True, exist_ok=True) for upload in request.files.getlist('images'): filename = secure_filename(upload.filename) if filename != '': save_path = str(UPLOAD_DIR / filename) save_path2 = save_path.split('users_img') filename = random_name() save_path = save_path2[0] + 'users_img\\' + filename + '.jpg' upload.save(save_path) user.img = '\\static\\users_img\\{}.jpg'.format(filename) category = Category(id=category_id, prog=form.category_prog.data, des=form.category_des.data, av=form.category_av.data, mrk=form.category_mrk.data, tw=form.category_tw.data) pas = form.password.data user.hassed_password = User.set_password(pas) session.add(user) session.add(category) session.commit() return redirect('/login') return render_template('register.html', title='Регистрация', form=form)
def reqister(): form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.password_again.data: return render_template('register.html', title='Registration', form=form, message="Passwords don't match") session = db_session.create_session() if session.query(User).filter(User.email == form.email.data).first(): return render_template('register.html', title='Registration', form=form, message="This user already exists") user = User( name=form.name.data, surname=form.surname.data, email=form.email.data, ) user.set_password(form.password.data) session.add(user) session.commit() return redirect('/login') return render_template('register.html', title='Registration', form=form)