def account(): # meal = Meal() # meal = meal.query.all() account_form = UpdateAccountForm() if account_form.validate_on_submit(): if account_form.picture.data: picture_file = save_picture(account_form.picture.data) current_user.image_file = picture_file current_user.username = account_form.username.data current_user.email = account_form.email.data db.session.commit() flash('your account has been updates!', 'success') return redirect(url_for('account')) elif request.method == 'GET': account_form.username.data = current_user.username account_form.email.data = current_user.email image_file = url_for('static', filename='profile_pics/' + current_user.image_file) user = current_user meal = user.meal[1] return render_template('account.html', title='Account', meal=meal, image_file=image_file, form=account_form)
def account(): form = UpdateAccountForm(obj=current_user) if form.validate_on_submit(): form.populate_obj(current_user) db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) return render_template('account.html', title='Account', form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email return render_template('account.html', title='Account', form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.Username = form.username.data current_user.email = form.email.data db.session.commit() flash("your account has been updated", "success") return redirect(url_for("account")) image_file = url_for('static', filename=current_user.user_image) return render_template("account.html", title="account", image_file=image_file, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash("Account info is updated!", 'success') # post-get-redirect pattern return redirect(url_for('account')) else: form.username.data = current_user.username form.email.data = current_user.email return render_template('account.html', title='Account', form=form)
def profil(): form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: picture_file = save_picture(form.picture.data) current_user.image_file = picture_file current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Dein Profil wurde aktualisiert.', 'success') return redirect(url_for('profil')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email image_file = url_for('static', filename='profile_images/' + current_user.image_file) return render_template('profil.html', title='Profil', image_file=image_file, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: picture_file = save_picture(form.picture.data) current_user.image_file = picture_file current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) elif request.method == 'GET': form.username.data = "loreto" form.email.data = current_user.email image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('account.html', title='Account', image_file=image_file, form=form)
def account(): posts = recentPost() image_file = url_for('static', filename='anime_thumbnail/downloads/') suggestedAnime = SuggestedContent(current_user) form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: picture_file = save_picture(form.picture.data) current_user.image_file = picture_file current_user.user_name = form.username.data current_user.email = form.email.data db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email image_file2 = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('account.html', title='Account', image_file=image_file, image_file2=image_file2, form=form, suggestedAnime=suggestedAnime, posts=posts)
def account(): form = UpdateAccountForm() giorni_disponibili = Giorni_Disponibili.query.filter_by( utente_id=current_user.id).first() comune = Comune.query.filter_by(id=current_user.comune_volontariato).first() if form.validate_on_submit(): current_user.email = form.email.data current_user.ruolo = form.ruolo.data print(form.comune_volontariato.data) current_user.orario_inizio = form.orario_inizio.data current_user.comune_volontariato = form.comune_volontariato.data current_user.orario_inizio = form.orario_inizio.data current_user.orario_fine = form.orario_fine.data giorni_disponibili = Giorni_Disponibili.query.filter_by(utente_id=current_user.id).first() giorni_disponibili.lunedi = form.lunedi.data giorni_disponibili.martedi = form.martedi.data giorni_disponibili.mercoledi = form.mercoledi.data giorni_disponibili.giovedi = form.giovedi.data giorni_disponibili.venerdi = form.venerdi.data giorni_disponibili.sabato = form.sabato.data giorni_disponibili.domenica = form.domenica.data db.session.commit() flash('Il tuo account e\' stato aggiornato!', 'success') return redirect(url_for('account')) elif request.method == "GET": form.email.data = current_user.email form.ruolo.data = current_user.ruolo form.comune_volontariato.data = current_user.comune_volontariato form.orario_inizio.data = current_user.orario_inizio form.orario_fine.data = current_user.orario_fine form.lunedi.data = giorni_disponibili.lunedi form.martedi.data = giorni_disponibili.martedi form.mercoledi.data = giorni_disponibili.mercoledi form.giovedi.data = giorni_disponibili.giovedi form.venerdi.data = giorni_disponibili.venerdi form.sabato.data = giorni_disponibili.sabato form.domenica.data = giorni_disponibili.domenica return render_template("account.html", title="Account", form=form, comune=comune, giorni_disponibili=giorni_disponibili)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: picture_file = save_picture(form.picture.data) current_user.image_file = picture_file current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Your account has been uspdated!', 'success') return redirect(url_for('account')) # Update 폼 submit시에 유저의 이름과 이메일이 폼에 적은 이름과 이메일로 변경됨 elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email # 그냥 GET요청만 날린경우(일반적으로 입장한 경우) 폼에 현재 유저의 이름과 이메일을 보여줌 image_file = url_for('static', filename='profile_pics/' + current_user.image_file) # static폴더의 profile_pics 디렉토리 안에 있는 유저의 이미지 파일 return render_template('account.html', title='Account', image_file=image_file, form=form)
def account(choice): form = UpdateAccountForm() page = request.args.get('page', 1, type=int) user = User.query.filter_by(username=current_user.username).first_or_404() if form.validate_on_submit(): if form.picture.data: picture_file = save_picture(form.picture.data) current_user.image_file = picture_file current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email image_file = url_for('static', filename='profile_pics/' + current_user.image_file) if choice == "donate": return render_template('donate.html', title='Account', image_file=image_file, form=form, user=user) elif choice == "ngo": return render_template('ngo.html', title='Account', image_file=image_file, form=form, user=user) elif choice == "deliver": return render_template('deliver.html', title='Account', image_file=image_file, form=form, user=user)