示例#1
0
def register() -> Response:

    form = RegistrationForm()

    if form.validate_on_submit():
        username = form.data['username']
        password = form.data['password']
        mail = form.data['mail']
        hashed_pswd = pbkdf2_sha256.hash(password)
        user = Users(username=username,
                     mail=mail,
                     password=hashed_pswd,
                     confirmed=False)
        db.session.add(user)
        db.session.commit()

        token = SendingMails(app, mail).generate_confirmation_token(user.mail)
        confirm_url = url_for('confirm_email', token=token, _external=True)
        html = render_template('users/activate.html', confirm_url=confirm_url)
        subject = "Please confirm your email"
        SendingMails(app, mail).send_email(user.mail, subject, html)
        flash('A confirmation email has been sent via email. :)', 'success')

        return redirect(url_for('unconfirmed'))

    return render_template('users/register.html', form=form)
示例#2
0
def add_course():
    form = RegistrationForm(csrf_enabled=False)
    if form.validate_on_submit():
        id = db_functions.insert_classes(
            form.lesson.data,
            form.lecturer.data,
            form.studio.data,
            form.day.data,
            form.time_from.data,
            form.time_to.data,
            form.age_group.data,
            form.level.data,
            form.course_type.data,
            form.address.data,
            form.address_city.data,
            form.link.data,
            form.email_address.data,
        )
        print("Inserted row as ID " + str(id))
        return redirect(url_for("seznam"))
    return render_template('registrace.html', form=form)