def cuenta(): 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('Su cuenta ha sido actualizada', 'success') return redirect(url_for('cuenta')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email posts = Post.query.filter_by(author=current_user).order_by(Post.date_posted.desc()).all() image_file = url_for('static', filename='/profile_pics/' + current_user.image_file) return render_template('cuenta.html', title='Mi Cuenta', image_file=image_file, form=form, posts=posts)
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 = current_user.username 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(): 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 = current_user.username 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(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.family_name = form.family_name.data current_user.email = form.email.data db.session.commit() flash('Your account has bin updated', 'succes') return redirect(url_for('account')) elif request.method == 'GET': form.family_name.data = current_user.family_name form.email.data = current_user.email image_file = url_for('static', filename='img/' + current_user.image_file) 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("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) 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 if form.avatar.data: f_name = save_avatar(form.avatar.data) current_user.avatar = f_name db.session.commit() flash('Account details 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 avatar = url_for('static', filename=f'profile_images/{current_user.avatar}') return render_template('account.html', title='Account', avatar=avatar, 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 else: current_user.image_file = "" current_user.username = form.username.data current_user.email = form.email.data db.session.commit() return redirect(url_for('account')) image_file = url_for('static', filename="profile_pics/" + current_user.image_file) return render_template('account.html', title="Student 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("Your account has been Updated", "success") return redirect(url_for('account')) elif request.method == 'GET': #loads with form filled with current_user data on a GET request form.username.data = current_user.username 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(): form = UpdateAccountForm() #on update button if form.validate_on_submit(): if form.picture.data: #if are there any new 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 #update data on db db.session.commit() flash('Your account has been updated!','success') return redirect(url_for('account')) elif request.method == 'GET': #fill form with existing data form.username.data = current_user.username form.email.data = current_user.email image_file = url_for('static', filename='profile_pics/'+current_user.image_file) #profile_pics is a dir return render_template('account.html', title='Account', 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() logout() flash('Your account info is updated successfully! Now You can Log In', 'success') return redirect(url_for('login')) 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(): '''this is a function to enable the users update the account information Args: form: load the UpdateAccountForm here form.username.data: username input from the form form.email.data: email input from the form picture_file: save the uploaded picture file current_user.image: user profile image in the record current_user.name: username in the record current_user.email: user email in the record request.method Return: render 'account.html' page resave the user data from the input form commit the change via db. ''' form = UpdateAccountForm() #check if the input of the form is valid if form.validate_on_submit(): #rewrite the record of the userdata(image_file,username,and email) with the new input 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 #commit the change via db. db.session.commit() #give a feedback and go back to the account page. 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) #render 'account.html' page return render_template('account.html', title='Account', image_file=image_file, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: image_file = save_picture(form.picture.data) current_user.image_file = image_file current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Account info updated', 'success') return redirect(url_for('users.account')) if request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email image_file = os.path.join('static', 'profile_pics/' + current_user.image_file) return render_template('account.html', title='Account', form=form, image_file=image_file)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.FirstName = form.FirstName.data current_user.MiddleName = form.MiddleName.data current_user.LastName = form.LastName.data current_user.DOB = form.DOB.data current_user.UserEmail = form.UserEmail.data current_user.PhoneNo = form.PhoneNo.data db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) elif request.method == 'GET': form.FirstName.data = current_user.FirstName form.MiddleName.data = current_user.MiddleName form.LastName.data = current_user.LastName form.DOB.data = current_user.DOB form.UserEmail.data = current_user.UserEmail form.PhoneNo.data = current_user.PhoneNo return render_template('account.html', title='Account', form=form)
def account(): #set the image file we want to pass to the template image_file = url_for('static',filename='profile_imgs/' + current_user.image_file) #instance of the UpdateAccountForm that exist in forms.py and parsing through render_template as a variable form = UpdateAccountForm() if form.validate_on_submit(): '''if form.picture.data: picture_file = save_picture(form.picture.data) current_user.image_file= picture_file''' #fetching username and email from db current_user.username = form.username.data current_user.email = form.email.data #commit to database 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',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 successfuly 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="images/" + current_user.image_file) #20:13 return render_template("account.html", title="Account", image_file=image_file, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): if form.image.data: current_user.image = save_image(form.image.data) current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Your account has been updated') return redirect(url_for('account')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email file_image = url_for('static', filename=f'pictures/{current_user.image}') return render_template('account.html', title='Acount', form=form, file_image=file_image)
def account(): #nous devons importer dabord updateaccount pour faire cette demarche fromflasklogin.... form = UpdateAccountForm() if form.validate_on_submit(): # si notre form est valide alors on peut faire des changements if form.picture.data: # pour sil ya une photo upload # picture_file = save_picture(form.picture.data) # save our picture current_user.image_file = picture_file current_user.username = form.username.data # le nouvel user sera envoyer a nos base de donnnees current_user.email = form.email.data db.session.commit() # ici nous confirmons notre changement flash('Your account has been updated!', 'success') return redirect(url_for('account')) # apres cela sa nous remets sur notre page account et on peut revoir sa elif request.method == 'GET': # Get alors on peut populate sur nos data directement dans la Db comme le chn es drct #Get nous prenonsles informations depuis notre base de donnnees form.username.data = current_user.username form.email.data = current_user.email image_file = url_for('static', filename='profile_pics/' + current_user.image_file) #image of our account #where users will put the imagefile return render_template('account.html', title='Account', image_file=image_file, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: #form.picture will just return the input type that it is expecting. it doesn't show if there actually is any data in there. So, we need to do 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": # Until the request is POST (button click), there will be the information displayed form.username.data = current_user.username 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(): form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: picture_file = save_picture( form.picture.data ) # pictured data from form is passed into the save function current_user.image_file = picture_file #the file name is returned and equated to current user image current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash(f"Your Account has been Updated Successfully", '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) return render_template('account.html', title='Account', 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) if current_user.image_file != "default.jpg": delete_old_picture(current_user.image_file) 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) return render_template("account.html", title="Account", image_file=image_file, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): print(form.picture.data) if form.picture.data: profile_pic = save_picture(form.picture.data) print(profile_pic) current_user.image_file = profile_pic current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Details updated successfully', '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='images/' + current_user.image_file) return render_template('account.html', title='Account', image_file=image_file, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): if form.image.data: picture = save_image(form.image.data) current_user.profile_picture = picture current_user.username = form.username.data current_user.email = form.email.data current_user.bio = form.bio.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 form.bio.data = current_user.bio profile_pic = url_for( "static", filename=f"profile_pics/{current_user.profile_picture}") return render_template("account.html", title="Account", profile_pic=profile_pic, form=form)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): # check if there is any profile picture. if form.picture.data: # set the profile picture. # save picture() is the function picture_file = save_picture(form.picture.data) current_user.image_file = picture_file # As the data is entered into form So that's why its form.username.data 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': # Populate the fields with the current_user data form.username.data = current_user.username 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(): form = UpdateAccountForm() if form.validate_on_submit(): # Validation & setting the picture-path if form.picture.data: pic_file = save_picture(form.picture.data) current_user.image_file = pic_file current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Your Account has been updated!', 'info') # Due to post-get-redirect pattern 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_pix/' + current_user.image_file) return render_template('account.html', title='Account', image_file=image_file, form=form)
def account(): page = request.args.get('page', 1, type=int) posts = Post.query.order_by(Post.date_posted.desc()).paginate(page=page, per_page=3) 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!', category='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) return render_template('account.html', title = 'Account', image_file = image_file,\ form = form, posts = posts, user = current_user)
def update_info(): form = UpdateAccountForm() image_file = url_for('static', filename='profile_pics/' + current_user.image_file) if form.validate_on_submit(): #checking if profile picture is updated if form.picture.data: picture_fn = save_picture(form.picture.data) current_user.image_file = picture_fn #update the user info in database current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Account info 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('update_info.html', title='update info', form=form, image_file=image_file)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.username = form.username.data current_user.email = form.email.data current_user.school = form.school.data current_user.college = form.college.data current_user.company1 = form.company1.data current_user.company2 = form.company2.data db.session.commit() flash('Account Details Updated!','success') return redirect(url_for('account')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email form.school.data = current_user.school form.college.data = current_user.college form.company1.data = current_user.company1 form.company2.data = current_user.company2 return render_template('account.html', title='Account', form=form, lat=float(get_coordinates()[0:7]), lon=float(get_coordinates()[7:]))
def account(): page = request.args.get('page', 1, type=int) last_donation = Donation.query.order_by(Donation.id.desc()).first() pastor = Pastor.query.order_by(Pastor.id.desc()).first() church = Church.query.order_by(Church.id.desc()).first() sermon = Sermon.query.order_by(Sermon.id.desc()).first() quote = Quote.query.order_by(Quote.id.desc()).first() sermons = Sermon.query.order_by(Sermon.id.desc()).paginate(page=page, per_page=6) upevents = UpEvent.query.order_by(UpEvent.id.desc()).paginate(page=page, per_page=6) donations = Donation.query.order_by(Donation.id.desc()).paginate( page=page, per_page=4) p_program = Past_P.query.order_by(Past_P.id.desc()).paginate(page=page, per_page=4) post = Post.query.order_by(Post.id.desc()).first() posts = Post.query.order_by(Post.id.desc()).paginate(page=page, per_page=6) upevent = UpEvent.query.order_by(UpEvent.id.desc()).first() per_t = (last_donation.received / last_donation.target) * 100 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 = current_user.username form.email.data = current_user.email image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('main/account.html', title='Account', image_file=image_file, form=form, posts=posts)
def account(): form = UpdateAccountForm() if form.validate_on_submit(): if form.picture.data: #set user's profile Picture picture_file = save_picture(form.picture.data) current_user.image_file = picture_file # will update account info current_user.username = form.username.data current_user.email = form.email.data db.session.commit() flash('Your Account has been Updated!', 'sucess') return redirect(url_for('account')) elif request.method == 'GET': # checks if updated info already belongs to another user form.username.data = current_user.username 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(): account_update_form = UpdateAccountForm() # Logic for updating user info once the update account form is submitted if account_update_form.validate_on_submit(): # Checking if there is any picture data, if there is we update the # existing profile picture data if account_update_form.picture.data: picture_file = save_picture(account_update_form.picture.data) current_user.image_file = picture_file current_user.username = account_update_form.username.data current_user.email = account_update_form.email.data db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) elif request.method == 'GET': account_update_form.username.data = current_user.username account_update_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=account_update_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', category='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) # cek profile picturenya ada atau tidak if os.path.exists('flaskblog' + image_file): pass else: # kalo gaada prof pic, set ke default current_user.image_file = 'default.jpg' db.session.commit() 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)