Пример #1
0
def signup():
    """Sign up form, no database interaction"""
    form = SignupForm()
    if form.validate_on_submit():
        flash('Signup requested for {}'.format(form.name.data))
        return redirect(url_for('main.hello_child', name=form.name.data))
    return render_template('signup.html', form=form)
Пример #2
0
def signup():
    form = SignupForm(request.form)
    if request.method == 'POST' and form.validate_on_submit():
        flash('Signup requested for {}'.format(form.username.data))
        # Code to add the student to the database goes here
        return redirect(url_for('main.index'))
    return render_template('signup.html', form=form)
Пример #3
0
def signup():
    if session.get('logged_in'):
        flash(f'You are already logged in.', 'warning')
        return redirect(request.args.get('next') or '/')

    form = SignupForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user:
            flash(
                f'The email address you entered already exists. Please try again.',
                'error')
            return redirect('/signup')

        password_hash = bcrypt.generate_password_hash(form.password.data)
        user = User(fullName=form.fullName.data,
                    email=form.email.data,
                    password=password_hash)
        db.session.add(user)
        db.session.commit()
        flash(f'Thank you for registering! You can now login.', 'success')
        return redirect('/login')
    else:
        if form.errors:
            error_msg = list(form.errors.values())[0][0]
            flash(f'{error_msg} Please try again.', 'error')

    return render_template('signup.html', form=form)
Пример #4
0
def signup():
    form = SignupForm()
    search = CityBlogSearchForm(request.form)
    if form.validate_on_submit():
        flash('Exciting, you have successfully signed up!')
        return redirect(url_for('main.home', title='Home', search=search))
    else:
        return render_template('signup.html', form=form, title="Signup")
Пример #5
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        db.session.add(user)
        db.session.commit()
        flash('You are now a registered user!')
        return redirect('/')
    return render_template('signup.html', form=form)
Пример #6
0
def sign_up():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        try:
            db.session.add(user)
            db.session.commit()
            flash('You are now a registered user!')
            return redirect(url_for('main.index'))
        except IntegrityError:
            db.session.rollback()
        flash(f'ERROR! Unable to register {user.username}. Please check your details are correct and try again.')
    return render_template('signup.html', form=form)
Пример #7
0
def signup():
    form = SignupForm(request.form)
    if request.method == 'POST' and form.validate():
        users = User(username=form.username.data, email=form.email.data)
        try:
            db.session.add(users)
            db.session.commit()
            flash('You are now a registered user!')
            return redirect(url_for('main.index'))
        except IntegrityError:
            db.session.rollback()
            flash('ERROR! Unable to register {}. Please check your details are correct and resubmit'.format(form.email.data), 'error')
    return render_template('signup.html', form=form)
Пример #8
0
def signup():
    form = SignupForm(request.form)
    search = CityBlogSearchForm(request.form)
    if request.method == 'POST' and form.validate_on_submit():
        new_user = User(username=form.username.data,
                        email=form.email.data,
                        name=form.name.data)
        try:
            db.session.add(new_user)
            db.session.commit()
            flash('Exciting, you have successfully signed up!')
            return redirect(url_for('main.home', title='Home', search=search))
        except IntegrityError:
            db.session.rollback()
            flash('ERROR! Sorry we were unable to register you. '
                  'Please check your details are correct and try again')
    return render_template('signup.html', form=form, title="Signup")
def signup():
    form = SignupForm(request.form)
    if request.method == 'POST' and form.validate():
        if form.role.data == "student":
            user = Student(name=form.name.data,
                           email=form.email.data,
                           student_ref=form.uni_id.data)
        else:
            user = Teacher(name=form.name.data,
                           title=form.title.data,
                           teacher_ref=form.uni_id.data,
                           email=form.email.data)
        user.set_password(form.password.data)
        try:
            db.session.add(user)
            db.session.commit()
            flash('You are now a registered user!')
            return redirect(url_for('main.index'))
        except IntegrityError:
            db.session.rollback()
            flash(
                'ERROR! Unable to register {}. Please check your details are correct and resubmit'
                .format(form.email.data), 'error')
    return render_template('signup.html', form=form)
Пример #10
0
def signup():
    form = SignupForm(request.form)
    if request.method == 'POST' and form.validate():
        flash('Signup requested for {}'.format(form.name.data))
        return redirect(url_for('main.index'))
    return render_template('signup.html', form=form)