Esempio n. 1
0
def upload_image():
    if request.method == 'POST':
        names = []
        for key, f in request.files.items():
            if key.startswith('file'):
                name = save_picture(f, os.path.join(basedir, 'static/images'))
                names.append(name)
        return jsonify(images=str(names))
Esempio n. 2
0
def setting():
    if not current_user.is_authenticated and not current_user.is_confirmed:
        return redirect(url_for('main.home'))
    form = SettingForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.username = form.username.data
        current_user.email = form.email.data
        if form.avatar.data:
            f = form.avatar.data
            name = save_picture(f, os.path.join(basedir, 'static/images'))
            current_user.avatar = name
        db.session.commit()
        return redirect(url_for('user.home', username=current_user.username))
    form.username.data = current_user.username
    form.name.data = current_user.name
    form.email.data = current_user.email
    return render_template('setting.html', form=form)
Esempio n. 3
0
def setting():
    if not current_user.is_confirmed:
        flash(
            "What did you use fake e-mail? Lmao now forget this account and create new one",
            "link")
        return redirect(url_for('main.home'))
    form = SettingForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.username = form.username.data
        if not current_user.email == form.email.data:
            current_user.email = form.email.data
            current_user.is_confirmed = False
        if form.avatar.data:
            f = form.avatar.data
            name = save_picture(f, os.path.join(basedir, 'static/images'))
            current_user.avatar = name
        flash(f'Your details have been changed', 'success')
        db.session.commit()
        return redirect(url_for('user.home', username=current_user.username))
    form.username.data = current_user.username
    form.name.data = current_user.name
    form.email.data = current_user.email
    return render_template('setting.html', form=form)