Пример #1
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        email = User.query.filter_by(email=form.email.data).first()
        username = User.query.filter_by(
            username=form.username.data).first()
        if email is not None:
            flash('Email must be unique.', 'danger')
            return redirect(url_for('user.register'))
        if username is not None:
            flash('Username must be unique.', 'danger')
            return redirect(url_for('user.register'))
        user = User(
            email=form.email.data,
            username=form.username.data,
            password=form.password.data
        )
        try:
            db.session.add(user)
            db.session.commit()
            login_user(user)
            flash('Thank you for registering.', 'success')
        except sqlalchemy.exc.IntegrityError as err:
            print('Handle Error:{0}'.format(err))
            flash('Something terrible happened.', 'danger')
        return redirect(url_for('user.register'))
        flash('Thank you for registering.', 'success')
    return render_template('user/register.html', form=form)
Пример #2
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():

        user = User(
            user_name=form.user_name.data,
            email=form.email.data,
            password=form.password.data
        )

        db.session.add(user)
        db.session.commit()
        db.session.refresh(user)

        # create default team
        team = Team(name="default", owner=user.id)
        db.session.add(team)
        db.session.commit()
        db.session.refresh(team)

        # add self to default team
        team_membership = TeamMembership(team_id=team.id, member_id=user.id)
        db.session.add(team_membership)
        db.session.commit()

        login_user(user)

        flash('Thank you for registering.', 'success')
        return redirect(url_for("user.ideas"))

    return render_template('user/register.html', form=form)
Пример #3
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        email = User.query.filter_by(email=form.email.data).first()
        username = User.query.filter_by(username=form.username.data).first()
        if email is not None:
            flash('Email must be unique.', 'danger')
            return redirect(url_for('user.register'))
        if username is not None:
            flash('Username must be unique.', 'danger')
            return redirect(url_for('user.register'))
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        try:
            db.session.add(user)
            db.session.commit()
            login_user(user)
            flash('Thank you for registering.', 'success')
        except sqlalchemy.exc.IntegrityError as err:
            print('Handle Error:{0}'.format(err))
            flash('Something terrible happened.', 'danger')
        return redirect(url_for('user.register'))
        flash('Thank you for registering.', 'success')
    return render_template('user/register.html', form=form)
Пример #4
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = User(email=form.email.data, password=form.password.data)
        db.session.add(user)
        db.session.commit()
        login_user(user)
        flash('Thank you for registering.', 'success')
        return redirect(url_for('main.home'))

    return render_template('user/register.html', form=form)
Пример #5
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = User(email=form.email.data, password=form.password.data)
        db.session.add(user)
        db.session.commit()

        login_user(user)

        flash("Thank you for registering.", "success")
        return redirect(url_for("user.members"))

    return render_template("user/register.html", form=form)
Пример #6
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = User(email=form.email.data, password=form.password.data)
        db.session.add(user)
        db.session.commit()

        login_user(user)

        flash('Thank you for registering.', 'success')
        return redirect(url_for('imagery.my_pictures'))

    return render_template('user/register.html',
                           form=form,
                           is_authenticated=current_user.is_authenticated)
Пример #7
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = Student(email=form.email.data, password=form.password.data)
        try:
            db.session.add(user)
            db.session.commit()
            login_user(user)
            flash('Thank you for registering.', 'success')
            return redirect(url_for("main.home"))
        except exc.SQLAlchemyError:
            flash('Something went wrong.', 'danger')
            return redirect(url_for("main.home"))

    return render_template('user/register.html', form=form)
Пример #8
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = User(
            email=form.email.data,
            password=form.password.data
        )
        db.session.add(user)
        db.session.commit()

        login_user(user)

        flash('Thank you for registering.', 'success')
        return redirect(url_for("user.members"))

    return render_template('user/register.html', form=form)
Пример #9
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = User(
            email=form.email.data,
            password=form.password.data
        )
        db.session.add(user)
        db.session.commit()

        login_user(user)

        flash('Gracias por suscribirte', 'success')
        return redirect(url_for("main.home"))

    return render_template('user/register.html', form=form)
Пример #10
0
def register():
    user_list = db.session.query(User.id, User.username,
                                 User.email).order_by(User.id)
    register_form = RegisterForm(request.form)
    #remove_form = RemoveUser(request.form)
    if register_form.validate_on_submit():
        User.create(username=register_form.username.data,
                    email=register_form.email.data,
                    password=register_form.password.data)
        flash("Successfully registered new user.", "success")
        return redirect(url_for("user.admin"))
    return render_template("user/admin.html",
                           user_list=user_list,
                           register_form=register_form,
                           remove_form=RemoveUser(),
                           remove_record=RemoveRecord())
Пример #11
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = Student(
            email=form.email.data,
            password=form.password.data
        )
        try:
            db.session.add(user)
            db.session.commit()
            login_user(user)
            flash('Thank you for registering.', 'success')
            return redirect(url_for("main.home"))
        except exc.SQLAlchemyError:
            flash('Something went wrong.', 'danger')
            return redirect(url_for("main.home"))

    return render_template('user/register.html', form=form)
Пример #12
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is not None:
            flash("You already have an account. Please sign in", "danger")
            return render_template("user/login.html",
                                   title="Please Login",
                                   form=form)

        user = User(email=form.email.data, password=form.password.data)
        db.session.add(user)
        db.session.commit()

        login_user(user)

        flash("Thank you for registering.", "success")
        return redirect(url_for("extractor.mydocuments"))

    return render_template("user/register.html", form=form)
Пример #13
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        existing_user = User.query.filter_by(email=form.email.data).first()
        print(existing_user)
        if existing_user is not None:
            # TODO: with message
            flash(
                'The Email address you chose is already used. Please enter different one.',
                'danger')
            return render_template('user/register.html', form=form)
        user = User(nickname=form.nickname.data,
                    email=form.email.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        login_user(user)

        flash('Thank you for registering.', 'success')
        return redirect(url_for("user.members"))

    return render_template('user/register.html', form=form)
Пример #14
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = User(name=form.name.data,
                    email=form.email.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()

        if current_app.config.get('MAIL_USERNAME'):
            user.send_activation_email()
            flash("Please check your email to activate your account.", "info")
        else:
            token = user.get_token()
            activation_url = url_for('account_activation.edit',
                                     token=token,
                                     _external=True)
            flash(
                Markup(f'Hi {user.name}, Welcome to the Sample App! ' +
                       f'Click <a href="{activation_url}">here</a> ' +
                       'to activate your account'), "info")
        return redirect(url_for("static_pages.home"))

    return render_template("user/register.html", form=form)