def register(): form = RegisterForm() global_init("db/blogs.sqlite") if form.validate_on_submit(): 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( surname=form.surname.data, name=form.name.data, age=form.age.data, city_from=form.city_from.data, books_read=form.books_read.data, books_written=form.books_written.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='Авторизация', form=form)
def register(): 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(email=form.email.data, surname=form.surname.data, name=form.name.data, age=form.age.data, position=form.position.data, speciality=form.speciality.data, address=form.address.data) user.set_password(form.password.data) session.add(user) session.commit() return redirect('/login') return render_template('register.html', title='Регистрация', form=form)
def registration(): 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(surname=form.surname.data, name=form.name.data, age=form.age.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='Регистрация', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.password_again.data: return render_template('register.html', title='Register', form=form, message="Пароли не совпадают", options=options) db_sess = db_session.create_session() if db_sess.query(Users).filter(Users.email == form.email.data).first(): return render_template('register.html', title='Register', form=form, message="Эта почта уже используется", options=options) user = Users(name=form.name.data, surname=form.surname.data, age=form.age.data, email=form.email.data, address=form.address.data, admin=0) user.set_password(form.password.data) db_sess.add(user) db_sess.commit() return redirect('/login') return render_template('register.html', title='Регистрация', form=form, options=options)
def register(): 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(surname=form.surname.data, name=form.name.data, age=int(form.age.data), email=form.email.data, is_varfarin=form.is_varfarin.data) user.set_password(form.password.data) session.add(user) session.commit() # сразу войти в систему user.is_active = True login_user(user, remember=False) current_user.is_active = True activity( f'new register email"{form.email.data}" name="{form.name.data} {form.surname.data}"' ) return redirect('/') # возврат на главное меню 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.login.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, address=form.address.data, email=form.login.data, ) user.set_password(form.password.data) session.add(user) session.commit() return "Вы успешно зарегистрированы!" return render_template("register.html", title="Регистрация", form=form)
def user_register(request): try: if request.method == 'POST': form = RegisterForm(request.POST, request.FILES) if form.is_valid(): email = form.cleaned_data['email'] firstname = form.cleaned_data['firstname'] lastname = form.cleaned_data['lastname'] password = form.cleaned_data['password'] phone = form.cleaned_data['phone'] address = form.cleaned_data['address'] gender = form.cleaned_data['gender'] city = form.cleaned_data['city'] try: photo = request.FILES['image'] handle_uploaded_file(photo, 'user') except Exception, e: print e pass try: if User.objects.filter(username__iexact=email).count() >= 1: messages.success(request, '%s already exist' % firstname) return redirect('register') user = User(username = email, first_name = firstname, last_name = lastname, email = email, is_active=True, is_staff=True) user.set_password(password) user.save() user_profile = UserProfile.objects.create( user=user, gender = gender, phone = phone, address = address, image = str(photo), is_active = True, country = city.country, city = city) return render_to_response('qcenter/register_confirm.html', {}, context_instance=RequestContext(request)) except Exception, e: print e return HttpResponseRedirect(reverse('user_login'))
def reqister(): form = RegisterForm() if form.validate_on_submit(): if not set(form.avatar_source.data.filename.lower()) <=\ set('abcdefghijklmnopqrstuvwxyz0123456789!\'#$' '%&\'()*+,-./:;<=>?@[\]^_`{|}~'): return render_template('register.html', title='Регистрация', form=form, message='Недопустимое название файла') if form.password_new.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, permission=form.permission.data, ) if form.phone_number.data: user.phone_number = form.phone_number.data if form.about.data: user.about = form.about.data if form.surname.data: user.surname = form.surname.data if form.avatar_source.data.filename: user.avatar_source = images.save(form.avatar_source.data) user.set_password(form.password_new.data) session.add(user) session.commit() return redirect('/login') return render_template('register.html', form=form)
def register(): 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="User already exists") user = User(email=form.email.data, surname=form.surname.data, name=form.name.data, about=form.about.data) user.set_password(form.password.data) session.add(user) session.commit() return redirect('/login') return render_template('register.html', title='Registration', form=form)
def register(): form = RegisterForm() db_sess = db_session.create_session() if form.validate_on_submit(): new_user = User() if len( db_sess.query(User).filter( User.email == form.email.data).all()) != 0: return render_template("register.html", form=form, title="Register", message="This email already in use") new_user.email = form.email.data new_user.address = form.address.data if form.shortname.data != "": new_user.shortname = form.shortname.data new_user.name = form.name.data new_user.surname = form.surname.data new_user.hashed_password = generate_password_hash(form.password.data) db_sess.add(new_user) db_sess.commit() return redirect(f"/finish/{new_user.id}") return render_template("register.html", form=form, title="Register")
def register(): base_params = {'css_path': url_for('static', filename='css/style.css')} form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.repeat_password.data: return render_template('register.html', title='Registration', form=form, message="Passwords doesn't match", **base_params) 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='The user with this email is already registered', **base_params) user = User(email=form.email.data, surname=form.surname.data, name=form.name.data, position=form.position.data, speciality=form.speciality.data, address=form.address.data) try: user.age = int(form.age.data) except ValueError: user.age = None user.set_password(form.password.data) session.add(user) session.commit() return redirect('/') return render_template('register.html', title='Registration', form=form, **base_params)
def register(): form = RegisterForm() if form.validate_on_submit(): if form.password.data != form.password_repeat.data: return render_template('register.html', form=form, message="Пароли не совпадают") session = create_session() if session.query(User).filter( (User.email == form.email.data) | (User.nickname == form.nickname.data)).first(): return render_template('register.html', form=form, message="Такой пользователь уже есть") user = User( nickname=form.nickname.data, email=form.email.data ) user.set_password(form.password.data) session.add(user) session.commit() return redirect('/login') return render_template('register.html', form=form)