当前位置: 首页>>代码示例>>Python>>正文


Python ProfileForm.validate_on_submit方法代码示例

本文整理汇总了Python中forms.ProfileForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python ProfileForm.validate_on_submit方法的具体用法?Python ProfileForm.validate_on_submit怎么用?Python ProfileForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.ProfileForm的用法示例。


在下文中一共展示了ProfileForm.validate_on_submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile(nickname):
    user = g.user
    print user.nickname
    form = ProfileForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            firstname = form.firstname.data
            lastname = form.lastname.data
            city = form.city.data
            state = form.state.data
            country = form.country.data
            zipcode = form.zipcode.data
            major = form.major.data
            degree = form.degree.data

            account = Account(user.id, firstname, lastname, city, state, country, zipcode, major, degree)
            db.session.add(account)
            db.session.commit()
            return render_template('profile.html',
                           title=nickname,
                           form=form,
                           user=user)
    return render_template('profile.html',
                           title=nickname,
                           form=form,
                           user=user)
开发者ID:czhangneu,项目名称:careermedley2,代码行数:28,代码来源:views.py

示例2: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile():

    form = ProfileForm()

    if form.validate_on_submit():

        user = User.query.filter_by(username=current_user.username).one()

        user.email = form.email.data

        if form.new_password1.data:
            if user.verify_password(form.current_password.data):
                user.password = form.new_password1.data
            else:
                db.session.commit()
                flash('Current password is not correct.', 'danger')
                return redirect(url_for('profile'))

        db.session.commit()

        flash('Profile changes saved.', 'success')
        return redirect(url_for('profile'))

    else:

        user = User.query.filter_by(username=current_user.username).one()
        
        form.email.data = user.email

        return render_template('profile.html', form=form)
开发者ID:kylecao,项目名称:cloud-pcap,代码行数:32,代码来源:app.py

示例3: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile():
    if current_user.is_authenticated():
        user = current_user
    else:
        user = None
    
    form = ProfileForm(obj=user)

    if not form.password or form.password == '':
        del form.password
    
    if form.validate_on_submit():
        if user:
            flash('Successfully updated your profile.')
        else:
            user = User()
            user.role = 1
            flash('Congratulations, you just created an account!')

        form.populate_obj(user)
        db.session.add(user)
        db.session.commit()

        if not current_user.is_authenticated():
            login_user(user)

        return redirect('/')

    return render_template('demographic.html', form=form)
开发者ID:aliyarahman,项目名称:student-application,代码行数:31,代码来源:views.py

示例4: edit_profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def edit_profile():
    if request.remote_addr != "127.0.0.1":
        return "UNAUTHORIZED ACCESS ATTEMPT REJECTED"
    form = ProfileForm()
    if form.validate_on_submit():
        if cache.get('ip_dict_valid'):
            cache.set('rerun_setup', True)
            cache.set('ip_dict_valid', True)

        file = request.files['picture']
        file.save(os.path.join(basedir,"app/static/profile.jpg"))

        pickling = {}
        #Get form data here!
        pickling["name"] = form.name.data
        pickling["location"] = form.location.data
        pickling["organization"] = form.organization.data
        pickling["about"] = form.about.data
        pickling["project"] = form.project.data
        pickling["project_description"] = form.project_description.data

        pickle.dump(pickling, open('pickledUser.p', 'wb'))
        
        #form.picture.save(filename)
        return redirect(url_for('profile'))
        
    #Get cpickle stuff here
    return render_template('edit_profile.html', form=form)
开发者ID:chungs1,项目名称:HackerNet,代码行数:30,代码来源:views.py

示例5: new_person

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def new_person():
    if not current_user.is_admin:
        return abort(401)
    form = ProfileForm()
    form.location.query = Location.query.order_by('name')
    form.brewery.query = Brewery.query.order_by('name')
    if form.validate_on_submit():
        person = Person(firstname=form.firstname.data,
                        lastname=form.lastname.data,
                        email=form.email.data,
                        password = bcrypt.generate_password_hash(form.password.data),
                        is_admin = form.is_admin.data,
                        is_manager = form.is_manager.data,
                        is_brewer = form.is_brewer.data)
        db.session.add(person)
        db.session.commit()
        if person.is_manager:
            location = Location.query.get(form.location.data.id)
            location.managers.append(person)
            db.session.add(location)
        if person.is_brewer:
            brewery = Brewery.query.get(form.brewery.data.id)
            brewery.brewers.append(person)
            db.session.add(brewery)
        db.session.commit()
        flash("Person added successfully", "success")
        return redirect(url_for("index"))
    if form.errors:
        flash("Changes to profile could not be saved.  Please correct errors and try again.", "error")
    return render_template('new_person.html',
                    title='Add a person',
                    form=form,
                    admin_template=True)
开发者ID:CapitalD,项目名称:Taplist,代码行数:35,代码来源:views.py

示例6: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile():
    form = ProfileForm(obj=current_user)

    if form.validate_on_submit():
        form.populate_obj(user)
        user.update_at = get_current_time()

        db.session.commit()

        flash('Public profile updated.', 'success')

    return render_template('user/profile.html', form=form)
开发者ID:LoyiLY,项目名称:fbone,代码行数:14,代码来源:views.py

示例7: modify_profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def modify_profile():
    if not current_user.confirmed:
        return render_template('auth/user_confirm.html', confirmed=False)
    form = ProfileForm()
    if form.validate_on_submit():
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        return redirect(url_for("main.user_page", username=current_user.username))
    form.about_me.data = current_user.about_me
    form.location.data = current_user.location
    return render_template('modify_profile.html', form=form, user=current_user)
开发者ID:Weilor,项目名称:poetbrain,代码行数:14,代码来源:views.py

示例8: users

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def users(current = -1):
    if current >= 0:
        users = User.query.all()
        user = User.query.filter(User.user_id == current).first()
        profileform = ProfileForm(obj=user)

        if request.method == 'POST' and profileform.validate_on_submit():
            if profileform.delete.data:
                user.deleted = True

            else:
                if profileform.undelete.data:
                    user.deleted = False

                user.fullname = profileform.fullname.data

                if profileform.password.data:
                    user.password = bcrypt.generate_password_hash(profileform.password.data)

            db.session.commit()
            return redirect('/users/edit/' + str(current))

        return render_custom_template('users.html', users=users, profileform=profileform, current=current)
    else:
        users = User.query.all()
        profileform = ProfileForm()

        if request.method == 'POST' and profileform.validate_on_submit():
            user = User(
                -1,
                profileform.username.data,
                bcrypt.generate_password_hash(profileform.password.data),
                profileform.fullname.data
            )
            db.session.add(user)
            db.session.commit()
            return redirect('/users')

        return render_custom_template('users.html', users=users, profileform=profileform, current=current)
开发者ID:kafeinnet,项目名称:kafeinnet-blog,代码行数:41,代码来源:views.py

示例9: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile():
		form = ProfileForm()
		user = g.user	
		if form.validate_on_submit():
				user.facebook = form.facebook.data if len(form.facebook.data) > 2 else "null"
				user.nickname = form.username.data if len(form.username.data) > 2 else user.nickname
				db.session.commit()
				flash("Profile updated successfully.")
				return redirect(url_for('index'))
		return render_template('profile.html',
		title= 'Profile',
		form = form,
		user = user)
开发者ID:julesbello,项目名称:nyuadtube,代码行数:15,代码来源:views.py

示例10: edit_profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def edit_profile():
    form = ProfileForm()
    if form.validate_on_submit():
	current_user.real_name = form.real_name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
	db.session.add(current_user)
	db.session.commit()
	flash('Your profile has been updated.')
	return redirect(url_for('main.user', username = current_user.name))
    form.real_name.data = current_user.real_name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form = form)
开发者ID:Jianwei-Wang,项目名称:my-flaskr,代码行数:16,代码来源:flaskr.py

示例11: user

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def user(nickname):
    print(request.args.get("jobkey"))
    user = g.user
    account = Account.query.filter_by(id=user.id).first()
    print "are we here? account: %s" % account
    if account is None:
        form = ProfileForm()
        if request.method == 'POST' and form.validate_on_submit():
            print "yes we got here....user.id: %s, user.email: %s" % (user.id, user.email)
            firstname = form.firstname.data
            lastname = form.lastname.data
            city = form.city.data
            state = form.state.data
            country = form.country.data
            zipcode = form.zipcode.data
            major = form.major.data
            degree = form.degree.data
            account = Account(id=user.id, firstname=firstname, lastname=lastname,
                        city=city, state=state, country=country, zipcode=zipcode,
                        major=major, degree=degree)
            print " account: %s" % account
            db.session.add(account)
            db.session.commit()
            jobForm = JobSearchForm()
            return render_template('user.html',
                                   nickname=nickname,
                                   user=user,
                                   form=jobForm)
        return render_template('profile.html', nickname=nickname,
                               user=user,
                               form=form)
    else:
        jobForm = JobSearchForm()
        if request.method == 'POST':
            if jobForm.validate_on_submit():
                getJobs = ProcessJobSearch()
                jobs = getJobs.job_search(jobForm.job.data, jobForm.location.data)
                for i in range(len(jobs)):
                    print "range (%d: %s)" % (i, jobs[i])
                    print '*' * 100
                return render_template('user.html',
                                       title='CareerMedley',
                                       form=jobForm, user=user, jobs=jobs)
    return render_template('user.html',
                           title=nickname,
                           form=jobForm,
                           user=user)
开发者ID:czhangneu,项目名称:careermedley,代码行数:49,代码来源:views.py

示例12: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile():
    user = User.query.filter(User.user_id == current_user.user_id).first()

    profileform = ProfileForm(obj=user)

    if request.method == 'POST' and profileform.validate_on_submit():
        user.fullname = profileform.fullname.data

        if profileform.password.data:
            user.password = bcrypt.generate_password_hash(profileform.password.data)

        db.session.commit()
        #login_user(User(user.user_id, user.username, user.password))

        return redirect('/profile')
    else:
        return render_custom_template('profile.html', profileform=profileform)
开发者ID:kafeinnet,项目名称:kafeinnet-blog,代码行数:19,代码来源:views.py

示例13: edit_profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def edit_profile(id):
    if not current_user.is_admin and not current_user.id == id:
        abort(401)
    form = ProfileForm()
    form.location.query = Location.query.order_by('name')
    form.brewery.query = Brewery.query.order_by('name')
    if form.validate_on_submit():
        person = Person.query.get_or_404(id)
        person.firstname = form.firstname.data
        person.lastname = form.lastname.data
        person.email = form.email.data
        if len(form.password.data) > 0:
            person.password = bcrypt.generate_password_hash(form.password.data)
        if current_user.is_admin:
            person.is_admin = form.is_admin.data
            person.is_manager = form.is_manager.data
            person.is_brewer = form.is_brewer.data
        db.session.add(person)
        db.session.commit()
        if person.is_manager:
            location = Location.query.get(form.location.data.id)
            location.managers.append(person)
            db.session.add(location)
            db.session.commit()
        if person.is_brewer:
            brewery = Brewery.query.get(form.brewery.data.id)
            brewery.brewers.append(person)
            db.session.add(brewery)
            db.session.commit()
        flash("Profile edited successfully", "success")
        return redirect(url_for("index"))
    person = Person.query.get_or_404(id)
    form.firstname.data = person.firstname
    form.lastname.data = person.lastname
    form.email.data = person.email
    if person.is_manager:
        form.location.data = person.locations[0]
    if person.is_brewer:
        form.brewery.data = person.breweries[0]
    if form.errors:
        flash("Changes to profile could not be saved.  Please correct errors and try again.", "error")
    return render_template('edit_profile.html',
                            title='Edit profile',
                            person=person,
                            form=form,
                            admin_template=True)
开发者ID:CapitalD,项目名称:Taplist,代码行数:48,代码来源:views.py

示例14: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile():
  page = request.environ.get('PAGE', {})
  page['user'] = current_user
  page['db'] = db
  form_content = page['form_content']

  if request.method == 'POST':
    form = ProfileForm()
    if form.validate_on_submit():
      print 'Whooo!!'
    else:
      print 'Booo!!'
    form_content = str(form)

  html = str(base(**page))
  html = html.format(form_content=page['form_content'])
  return html
开发者ID:jackij,项目名称:FPWeb,代码行数:19,代码来源:dash.py

示例15: profile

# 需要导入模块: from forms import ProfileForm [as 别名]
# 或者: from forms.ProfileForm import validate_on_submit [as 别名]
def profile():

    form = ProfileForm()

    if form.validate_on_submit():

        user = User.query.filter_by(username=current_user.username).one()

        user.email = form.email.data

        if form.new_password1.data:
            if user.verify_password(form.current_password.data):
                user.password = form.new_password1.data
            else:
                db.session.commit()
                flash('Current password is not correct.', 'danger')
                return redirect(url_for('profile'))

        db.session.commit()

        flash('Profile changes saved.', 'success')
        return redirect(url_for('profile'))

    else:

        user = User.query.filter_by(username=current_user.username).one()
        
        photos = Photo.query.filter_by(user_id=user.id).order_by(desc(Photo.vote_value)).all()

        votes = {}

        for photo in photos:
            temp_votes = Vote.query.filter_by(photo_id=photo.id).all()
            votes[photo.id] = {'up': 0, 'down': 0}
            for vote in temp_votes:
                if vote.value > 0:
                    votes[photo.id]['up'] += 1
                else:
                    votes[photo.id]['down'] += 1

            votes[photo.id]['total'] = votes[photo.id]['up'] - votes[photo.id]['down']

        form.email.data = user.email

        return render_template('profile.html', form=form, photos=photos, votes=votes)
开发者ID:packetpounder,项目名称:donkey,代码行数:47,代码来源:app.py


注:本文中的forms.ProfileForm.validate_on_submit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。