def user(username): user = User.query.filter_by(username=username).first_or_404() form = EditProfileForm(current_user.username) if form.validate_on_submit(): current_user.username = form.username.data current_user.first_name = form.first_name.data current_user.last_name = form.last_name.data current_user.email = form.email.data db.session.commit() flash('Your changes have been saved.') return redirect(url_for('auth.user', username=current_user.username)) elif request.method == 'GET': form.username.data = current_user.username form.first_name.data = current_user.first_name form.last_name.data = current_user.last_name form.email.data = current_user.email print(user.projects.all()) return render_template('auth/user.html', title='User preferences', user=user, form=form, projects=user.projects.all(), pform=UpdatePasswordForm())
def edit_profile(): form = EditProfileForm(current_user.mob, current_user.nickname) if form.validate_on_submit(): current_user.nickname = form.nickname.data current_user.mob = form.mob.data db.session.commit() flash('Your changes have been saved.') return redirect(url_for('main.edit_profile')) elif request.method == 'GET': form.nickname.data = current_user.nickname form.mob.data = current_user.mob return render_template('auth/editprofile.html', form=form)
def edit_profile(): form = EditProfileForm(current_user.username) if form.validate_on_submit(): current_user.username = form.username.data db.session.commit() flash('Your changes have been saved.') return redirect(url_for('auth.edit_profile')) elif request.method == 'GET': form.username.data = current_user.username form.first_name.data = current_user.first_name form.last_name.data = current_user.last_name return render_template('edit_profile.html', title='Edit Profile', form=form)
def edit_profile(): form = EditProfileForm() if form.validate_on_submit(): current_user.name = form.name.data current_user.location = form.location.data current_user.about_me = form.about_me.data db.session.add(current_user) flash('Your profile has been updated') return redirect(url_for('.user', username=current_user.username)) form.name.data = current_user.name form.location.data = current_user.location form.about_me.data = current_user.about_me return render_template('edit_profile.html', form=form)
def edit_profile(): token = current_user.get_reset_password_token() user = User.verify_reset_password_token(token) form = EditProfileForm(current_user.username) if form.validate_on_submit(): current_user.username = form.username.data user.set_password(form.password.data) db.session.commit() flash('Your changes have been saved.') return redirect(url_for('auth.edit_profile')) elif request.method == 'GET': form.username.data = current_user.username return render_template('auth/edit_profile.html', title='Edit profile', form=form)
def edit_profile(): form = EditProfileForm() if form.validate_on_submit(): current_user.name = form.name.data current_user.location = form.location.data current_user.about_me = form.about_me.data db.session.add(current_user._get_current_object()) db.session.commit() flash('Your profile has been updated.') return redirect(url_for('.user', username=current_user.username)) form.name.data = current_user.name form.location.data = current_user.location form.about_me.data = current_user.about_me return render_template('edit_profile.html', form=form)
def edit_profile(): user = current_user form = EditProfileForm(current_user.username) if form.validate_on_submit(): user.username = form.username.data user.about_me = form.about_me.data db.session.commit() return redirect(url_for("main.user", username=user.username)) elif request.method == 'GET': form.username.data = user.username form.about_me.data = user.about_me return render_template("edit_profile.html", form=form)
def profile(username): user = User.query.filter_by(username=username).first_or_404() form = EditProfileForm() if form.validate_on_submit(): current_user.username = form.username.data current_user.about_me = form.about_me.data db.session.commit() flash('Your changes have been saved.') return redirect(url_for('auth.profile', username=current_user.username)) elif request.method == 'GET': form.username.data = current_user.username form.about_me.data = current_user.about_me return render_template('auth/profile.html', user=user, title='Edit Profile', form=form)
def edit_user_profile(): form = EditProfileForm() title = 'Edit profile' if form.validate_on_submit(): if form.email_validate() or form.username_validate( ) or form.old_password_validate() != True: pass else: current_user.set_password(form.new_password.data) current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Данные успешно сохранены!') return redirect(url_for('auth.edit_user_profile')) return render_template('user_profile.html', form=form, title=title)
def edit_profile(): form = EditProfileForm(current_user.username, current_user.email) if form.validate_on_submit(): current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash("Your profile information has been updated.") return redirect(url_for("main.user", username=current_user.username)) elif request.method == "GET": form.username.data = current_user.username form.email.data = current_user.email return render_template("auth/edit_profile.html", title="Edit Profile", form=form)
def edit_profile(username): user=User.query.filter_by(username=username).first_or_404() if username != current_user.username: return redirect(url_for('homepage')) form = EditProfileForm(prefer_language=('py' if current_user.prefer_language == 'py' else 'cpp')) if form.validate_on_submit(): current_user.username = form.username.data current_user.email = form.email.data current_user.prefer_language = form.prefer_language.data db.session.commit() flash('Your change has been saved') return redirect(url_for('homepage')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email return render_template('auth/edit_profile.html', user=user, title='Edit Profile', form=form)
def edit_profile() -> str: form = EditProfileForm( original_username=current_user.username, original_email=current_user.email ) if form.validate_on_submit(): user = User.query.filter_by(username=current_user.username).first() if user: user.username = form.username.data if form.email.data != current_user.email: email.send_change_email_confirmation(form.email.data, user) flash("Check your email to confirm the email address change.") db.session.commit() flash("You change your profile data.") return redirect(url_for("main.user", username=current_user.username)) elif request.method == "GET": form.username.data = current_user.username form.email.data = current_user.email return render_template("auth/form.html", title="Edit Profile", form=form)
def edit_profile(): form = EditProfileForm(current_user.username) print("not here") print(form.username.data) print(form.about_me.data) if form.validate_on_submit(): current_user.username = form.username.data print("in here") current_user.about_me = form.about_me.data db.session.commit() flash('Username and profile changed', 'success') return redirect(url_for('auth.user', username=current_user.username)) # elif request.method == 'GET': # form.username.data = current_user.username # form.about_me.data = current_user.about_me # print("in here instead") return render_template('edit_profile.html', title='Edit Profile', form=form)
def edit_profile(): form = EditProfileForm() if form.validate_on_submit(): name = form.name.data email = form.email.data job_title = form.job_title.data #edit a user try: current_user.edit(name, email, job_title) # Update successful flash( 'User {}, updated with email={}, name={}, job_title={}'.format( current_user.id, current_user.email, current_user.name, current_user.get_meta()['job_title']), 'teal') return redirect(url_for('auth.view_profile')) except Exception as e: # Update unsuccessful error_json = e.args[1] error = json.loads(error_json)['error']['message'] flash("Error: {}".format(error), 'red') form.name.data = current_user.name form.email.data = current_user.email meta = current_user.get_meta() if meta: form.job_title.data = meta['job_title'] return render_template('auth/edit_profile.html', title='Edit Profile', form=form)