當前位置: 首頁>>代碼示例>>Python>>正文


Python EditProfileForm.validate_on_submit方法代碼示例

本文整理匯總了Python中forms.EditProfileForm.validate_on_submit方法的典型用法代碼示例。如果您正苦於以下問題:Python EditProfileForm.validate_on_submit方法的具體用法?Python EditProfileForm.validate_on_submit怎麽用?Python EditProfileForm.validate_on_submit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在forms.EditProfileForm的用法示例。


在下文中一共展示了EditProfileForm.validate_on_submit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit_profile():
    #form = EditProfileForm(g.user.nickname)
    form = EditProfileForm()
    avatar_form = EditAvatarForm()
    cover_form = EditCoverForm()
    # ----- If form is used
    print 'EP', form.validate_on_submit()
    if form.validate_on_submit():
        g.user.name = form.name.data
        g.user.show_email = form.show_email.data
        g.user.bio = form.bio.data
        g.user.sex = form.sex.data
        g.user.slogan = form.slogan.data
        g.user.status = form.status.data
        g.user.location = form.location.data
        db.session.add(g.user)
        db.session.commit()
        flash('Your changes have been saved.', 'success')
        return redirect(url_for('edit_profile'))
    else:
        form.name.data = g.user.name
        form.show_email.data = g.user.show_email
        form.bio.data = g.user.bio
        form.sex.data = g.user.sex
        form.slogan.data = g.user.slogan
        form.status.data = g.user.status
        form.location.data = g.user.location
    return render_template(
        "site/%s/edit_profile.html" % (cordon.config['TEMPLATE']),
        user = g.user,
        form = form,
        avatar_form = avatar_form,
        cover_form = cover_form,
        )
開發者ID:CordonSN,項目名稱:cordon,代碼行數:36,代碼來源:views.py

示例2: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data
        current_user.last_name = form.last_name.data
        current_user.location = form.location.data
        current_user.national_id = form.national_id.data
        current_user.phone_number = form.phone_number.data
        current_user.marital_status = form.marital_status.data
        current_user.gender = form.gender.data
        current_user.d_o_b = form.d_o_b.data

        db.session.add(current_user)
        flash('Your profile has been updated.')
        return redirect(url_for('.user', username=current_user.username))
    form.first_name.data = current_user.first_name
    form.last_name.data = current_user.last_name
    form.location.data = current_user.location
    form.national_id.data = current_user.national_id
    form.phone_number.data = current_user.phone_number
    form.marital_status.data = current_user.marital_status
    form.gender.data = current_user.gender
    form.d_o_b.data = current_user.d_o_b

    return render_template('edit_profile.html', form=form, user=user)
開發者ID:Kimanicodes,項目名稱:wananchi,代碼行數:27,代碼來源:views.py

示例3: edit

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit():
    form = EditProfileForm()
    if form.validate_on_submit():
        g.user.emailReminders = form.emailReminders.data
        g.user.pmReminders = form.pmReminders.data
        if not form.email.data:
            g.user.email = None
            g.user.emailConfirmed = None
            db.session.add(g.user)
            db.session.commit()
            flash('Profile Successfully Updated.', 'info')
            return redirect(url_for('edit'))
        if form.email.data == g.user.email and g.user.emailConfirmed:
            db.session.add(g.user)
            db.session.commit()
            flash('Profile Successfully Updated.', 'info')
            return redirect(url_for('edit'))
        provisionalEmail = form.email.data
        if g.user.email is None or g.user.emailConfirmed == False:
            g.user.email = provisionalEmail
            g.user.emailConfirmed = False
            db.session.add(g.user)
            db.session.commit()
        message.send_email('Confirm Your Account', [provisionalEmail], 'confirmation',
            user=g.user, token=g.user.generate_confirmation_token(email=provisionalEmail))
        flash('A confirmation message has been sent to you. Please check your spam or junk folder.', 'warning')
        return redirect(url_for('edit'))

    form.email.data = g.user.email
    form.emailReminders.data = g.user.emailReminders
    form.pmReminders.data = g.user.pmReminders

    return render_template('editprofile.html',
                           form=form,
                           user=g.user)
開發者ID:brandonsato,項目名稱:cbbpoll,代碼行數:37,代碼來源:views.py

示例4: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit_profile():
    form = EditProfileForm()
    c = Config()
    if form.validate_on_submit():
        current_user.bio = form.bio.data
        current_user.address = form.address.data
        current_user.phone_number = form.phone_number.data
        current_user.website = form.website.data
        current_user.public_email = form.email.data
        current_user.f1 = form.featured1.data
        if form.image.data:
            filename = form.image.data.filename
            get_queue().enqueue(process_image, 
                                type='image',
                                filename=filename,
                                data =form.image.data.read(),
                                user_id=current_user.id)
        if form.pdf.data:
            filename = form.pdf.data.filename
            get_queue().enqueue(process_image, 
                                type='pdf',
                                filename=filename,
                                data =form.pdf.data.read(),
                                user_id=current_user.id)
        db.session.commit()
        return redirect(url_for('vendor.view_profile'))
    form.bio.data = current_user.bio
    form.address.data = current_user.address
    form.phone_number.data = current_user.phone_number
    form.website.data = current_user.website
    form.email.data = current_user.public_email
    form.featured1.data = current_user.f1
    return render_template('vendor/edit_profile.html', form=form)
開發者ID:hack4impact,項目名稱:reading-terminal-market,代碼行數:35,代碼來源:views.py

示例5: edit

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit():
	form = EditProfileForm()

	if form.validate_on_submit():
		current_user.firstname = form.firstname.data
		current_user.lastname = form.lastname.data
		current_user.address = form.address.data
		current_user.city = form.city.data
		current_user.state = form.state.data
		current_user.zipcode = form.zipcode.data
		current_user.country = form.country.data
		current_user.about_me = form.about_me.data
		current_user.user_disabled = form.user_disabled.data

		model.session.add(current_user)
		model.session.commit()

		flash('Your changes have been saved!')
		return redirect(url_for('edit'))
		#renders the fields with data from database
	else:
		form.firstname.data= current_user.firstname
		form.lastname.data= current_user.lastname 
		form.address.data= current_user.address 
		form.city.data= current_user.city 
		form.state.data= current_user.state
		form.zipcode.data= current_user.zipcode
		form.country.data= current_user.country
		form.about_me.data= current_user.about_me
		form.user_disabled.data= current_user.user_disabled

	return render_template("edit_profile.html",
							form=form)
開發者ID:Cjames21082,項目名稱:Hackbright-Project--Soccer,代碼行數:35,代碼來源:views.py

示例6: edit

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit():
    form = EditProfileForm()
    if form.validate_on_submit():
        pic_file = request.files[form.profile_pic.name]
        if pic_file and allowed_file(pic_file.filename):
            filename = secure_filename(pic_file.filename)
            folder = os.path.join(current_app.config['UPLOAD_FOLDER'],
                                  PROFILE_PIC_UPLOAD_SUBFOLDER)
            if not os.path.exists(folder):
                os.makedirs(folder)
            pic_file.save(os.path.join(folder, filename))
            current_user.profile_pic_url = url_for('.profile_pic',
                                                   filename=filename)

        current_user.name = form.name.data
        current_user.email = form.email.data
        db.session.add(current_user)
        db.session.commit()
        flash("Account information saved successfully", "success")
        return redirect(url_for('.show'))

    if request.method == 'GET':
        form.name.data = current_user.name
        form.email.data = current_user.email

    return render_template('account/edit.html', form=form)
開發者ID:andela-hthuo,項目名稱:AssetTracker,代碼行數:28,代碼來源:views.py

示例7: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.name = form.name.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
    return render_template('apartment/edit_profile.html', form=form)
開發者ID:rjames86,項目名稱:fun-endpoints,代碼行數:11,代碼來源:views.py

示例8: editprofile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def editprofile():

    form = EditProfileForm(obj=current_user)

    # form.populate_obj(user)

    if form.validate_on_submit():
        return render_template('editprofile.html', title="Username", user=current_user, form=form)

    return render_template('editprofile.html', title="Username", user=current_user, form=form)
開發者ID:ArielInfante,項目名稱:HappyHour-Flask,代碼行數:12,代碼來源:views.py

示例9: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit_profile():
    user = User.query.get(session['user_id'])
    form = EditProfileForm(obj=user)
    form.populate_obj(user)
    if form.validate_on_submit():
        print user
        db.session.add(user)
        print "session add user"
        db.session.commit()
        print "session commit user"
        return redirect(url_for('profile'))
    return render_template('edit_profile.html', form=form)
開發者ID:kajun,項目名稱:flaskapp_safety_training_website,代碼行數:14,代碼來源:authenticate.py

示例10: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
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.update_user_profile(current_user)
        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)
開發者ID:heidricklevi,項目名稱:blog,代碼行數:14,代碼來源:application.py

示例11: editUserInfo

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def editUserInfo():
    form = EditProfileForm()
    user=current_user
    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
        current_user.contactMe = form.mycontact.data
        current_user.avatar = form.avatar.data
        db.session.add(current_user)
        db.session.commit()
        flash(u'修改個人信息成功')
    return render_template('info/editUserInfo.html', form=form, user=user)
開發者ID:Can2studio,項目名稱:jxnugo,代碼行數:15,代碼來源:views.py

示例12: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
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('main.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)
開發者ID:mapingfan,項目名稱:MyWebApp,代碼行數:15,代碼來源:views.py

示例13: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit_profile():
    form = EditProfileForm(g.user.nickname)
    flash(g.user.nickname)

    if form.validate_on_submit():
        print 'inside validate_on_submit'
        g.user.about_me = form.about_me.data
        g.user.nickname = form.nickname.data
        db.session.add(g.user)
        db.session.commit()
        flash("About me save !")
        return redirect(url_for('index'))

    return render_template('edit_profile.html', form=form)
開發者ID:archieyang,項目名稱:microblog,代碼行數:16,代碼來源:views.py

示例14: editprofile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def editprofile():
    form = EditProfileForm(current_user.name)
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.email = form.email.data
        current_user.phone = form.phone.data
        db_session.add(current_user)
        db_session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('editprofile'))
    elif request.method != "POST":
        form.name.data = current_user.name
        form.email.data = current_user.email
        form.phone.data = current_user.phone
    return render_template('editprofile.html', form=form)
開發者ID:payoung,項目名稱:cl-app,代碼行數:17,代碼來源:views.py

示例15: edit_profile

# 需要導入模塊: from forms import EditProfileForm [as 別名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 別名]
def edit_profile():
	form = EditProfileForm(g.user.username)
	if form.validate_on_submit():
		g.user.username = form.username.data
		g.user.about = form.about.data
		db.session.add(g.user)
		db.session.commit()
		flash('Your changes have been saved.')
		return redirect(url_for('user', username = g.user.username))
	else:
		form.username.data = g.user.username
		form.about.data = g.user.about
	return render_template('edit_profile.html', 
		title = 'Edit Profile',
		form = form)
開發者ID:allisonurban,項目名稱:1sd0,代碼行數:17,代碼來源:views.py


注:本文中的forms.EditProfileForm.validate_on_submit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。