Exemple #1
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)
        user.set_password(form.password.data)
        user.level = 3
        user.active = 1
        db.session.add(user)
        db.session.commit()
        flash('Congratulations, you are now a registered user!', 'success')
        return redirect(url_for('login'))
    breadcrumbs = [{
        'link': url_for('index'),
        'text': 'Home',
        'visible': True
    }, {
        'text': 'Register'
    }]
    return render_template('auth/register.html',
                           title='Register',
                           form=form,
                           breadcrumbs=breadcrumbs)
Exemple #2
0
def add_monkey():
    form = RegistrationForm()
    if form.validate_on_submit():
        monkey = Monkey()
        form.populate_obj(monkey)
        monkey.add_friend(monkey)
        db.session.add(monkey)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('addMonkey.html', title='Add Monkey', form=form)
Exemple #3
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)
        db.session.add(user)
        db.session.commit()
        login_user(user)
        return redirect(url_for('/index'))
    return render_template('register.html', title = 'Register', form = form)
Exemple #4
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = Account()
        form.populate_obj(user)
        db.session.add(user)
        db.session.commit()
        login_user(user)
        return redirect(url_for('tracking.index'))
    return render_template('register.html', form=form)
Exemple #5
0
    def register_view(self):
        form = RegistrationForm(request.form)
        if helpers.validate_form_on_submit(form):
            user = User()

            form.populate_obj(user)

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

            login.login_user(user)
            return redirect(url_for('.index'))
        link = '<p>Already have an account? <a href="' + url_for('.login_view') + '">Click here to log in.</a></p>'
        self._template_args['form'] = form
        self._template_args['link'] = link
        return super(MyAdminIndexView, self).index()
Exemple #6
0
def registration():
    if current_user.is_authenticated:
        return redirect(url_for('account'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User.query.filter_by(mail=form.mail.data).first()
        if user:  # TODO this mail check doesn't work. Fix it
            form.mail.errors.append(
                "Пользователь с таким ящиком уже существует.")
            render_template('auth.html', form=form, registration_page=True)
        user = User()
        form.populate_obj(user)
        user.save()
        flash("Аккаунт успешно создан", "success")
        return redirect(url_for("account"))
    return render_template('auth.html', form=form, registration_page=True)