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


Python forms.EditProfileForm类代码示例

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


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

示例1: edit_profile

def edit_profile(request):
    """
    view untuk fungsionalitas perubahan data profile
    account
    """
    if request.POST:
        old_picture = request.user.profile.picture
        form = EditProfileForm(request.POST, request.FILES,
            instance=request.user.profile)
        if form.is_valid():
            if 'picture' in request.FILES:
                from os import unlink
                if old_picture.name != 'profpic/default.jpg':
                    unlink(old_picture.path)
            form.save()
            request.user.email = form.cleaned_data['email']
            request.user.first_name = form.cleaned_data['first_name']
            request.user.last_name = form.cleaned_data['last_name']
            request.user.save()
            messages.info(request, _('Profile updated'))
            return HttpResponseRedirect(reverse('self_profile'))
    else:
        form = EditProfileForm(instance=request.user.profile,
                initial={'email': request.user.email,
                         'first_name': request.user.first_name,
                         'last_name': request.user.last_name})
    return render_to_response('accounts/edit_profile.html',
            {'form': form},
            context_instance=RequestContext(request))
开发者ID:sakti,项目名称:ittelkomnewsmap,代码行数:29,代码来源:views.py

示例2: edit_profile

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,代码行数:34,代码来源:views.py

示例3: edit

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,代码行数:35,代码来源:views.py

示例4: edit_profile

def edit_profile(request,id):
    if request.method =='GET' :

        if request.user.is_authenticated():
            now =  timezone.make_aware(datetime.now(),timezone.get_default_timezone())
            now = formats.date_format(now,"SHORT_DATETIME_FORMAT")
            data = User.objects.get(pk=id)

            form = EditProfileForm()
            dv = {'first_name':data.first_name,'last_name':data.last_name,'email':data.email}
            form = EditProfileForm(dv)
            return render(request, 'userprofile_edit.html', {'form':form,'timezones':pytz.common_timezones,"date":str(now)})

        else:
            return redirect('/authen/')
    elif request.method == 'POST' :
        now =  timezone.make_aware(datetime.now(),timezone.get_default_timezone())
        now = formats.date_format(now,"SHORT_DATETIME_FORMAT")
        data = User.objects.get(pk=id)
        if request.POST.get('updateuser'):
            user = request.user
            time = request.POST['timezone']
            form = EditProfileForm(request.POST)
            time_user = UserProfile.objects.filter(pk=id).update(user_timezone=time)
            request.session['django_timezone'] = request.POST['timezone']
            if form.is_valid():
                user.first_name = request.POST['first_name']
                user.last_name = request.POST['last_name']
                user.email = request.POST['email']
                user.save()
                return redirect('/userprofile/')
        elif request.POST.get('canceledituser'):
                return redirect('/userprofile/')
开发者ID:0ldragonl0,项目名称:toppic,代码行数:33,代码来源:views.py

示例5: edit

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,代码行数:33,代码来源:views.py

示例6: profile

def profile():
    if 'email' not in session:
        return redirect(url_for('login'))
   
    user = User.query.filter_by(email = session['email']).first()

    if user is None:
        return redirect(url_for('login'))
    else:
        form = EditProfileForm()
        if request.method == 'POST':
            if form.validate() == False:
                return render_template('profile.html', form=form, title='profile', user=user)
            elif form.submit.data is True:
                user = User.query.filter_by(email=session['email']).first()
                if len(form.password.data) > 0:
                    user.password = form.password.data
                user.name = form.name.data
                db.session.commit()
	    elif form.verify.data is True:
		token = generate_confirmation_token(session['email'])
                confirm_url = url_for('confirm', token=token, _external=True)
    		html = render_template('confirm.html', confirm_url=confirm_url)
		subject = "Mylink: confirm email"
		send_email(session['email'], subject, html)
		return render_template('verificationsent.html')

            return redirect(url_for('index'))
        user = User.query.filter_by(email=session['email']).first()

        return render_template('profile.html', form=form, title='profile', user=user)
开发者ID:nawns,项目名称:MyLink,代码行数:31,代码来源:main.py

示例7: editProfile

def editProfile(request):	
	if request.method == 'POST':
		form = EditProfileForm(request.POST, request.FILES)
		if form.is_valid():
			cleaned_data = form.clean()
			first_name = cleaned_data['first_name'].strip()
			last_name = cleaned_data['last_name'].strip()
			email = cleaned_data['emailAddress']
			dorm = cleaned_data['dorm']
			pic = request.FILES.get('pic','')
			user = User.objects.get(username = request.user)
			userdata = user.userdata
			if first_name.strip():
				user.first_name = first_name
			if last_name.strip():
				user.last_name = last_name
			if email.strip():
				user.email = email
			if dorm.strip():
				userdata.dorm = dorm
			if pic:
				userdata.pic = pic
			user.save()
			userdata.save()
			return HttpResponseRedirect('/')
	else:
		user = request.user
		userdata = user.userdata
		data = {'first_name':user.first_name, 'last_name':user.last_name, 'emailAddress':user.email, 'dorm':userdata.dorm}
		form = EditProfileForm(initial = data)
	
	return render(request, 'editProfile.html', {'form':form})
开发者ID:allevitan,项目名称:olinbartering,代码行数:32,代码来源:views.py

示例8: edit_profile

def edit_profile(request, username):
	if username != request.user.username:
		return HttpResponseForbidden()
	if request.method == 'POST':
		form = EditProfileForm(request.POST, request.user)
		if form.is_valid():
			cd = form.cleaned_data
			p = request.user.profile
			for item in cd:
				try:
					if getattr(request.user, item) != cd[item]:
						setattr(request.user, item, cd[item])
				except:
					if getattr(p, item) != cd[item]:
						setattr(p, item, cd[item])
			request.user.save()
			p.save()
			return HttpResponseRedirect(reverse(profile, kwargs={'username': request.user.username}))
		else:
			return render_to_response(request, 'edit_profile.html', {'form': form})
	user_data = {}
	for field in EditProfileForm():
		try:
			if 'password' not in field.name:
				user_data[field.name] = getattr(request.user, field.name)
		except:
			if 'password' not in field.name:
				user_data[field.name] = getattr(request.user.profile, field.name)
	form = EditProfileForm(initial=user_data)
	return render_to_response(request, 'edit_profile.html', {'form': form})
开发者ID:abshkd,项目名称:benzene,代码行数:30,代码来源:views.py

示例9: edit

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,代码行数:26,代码来源:views.py

示例10: edit

def edit(request):
    """
    Obsługuje dwa typy żądań:
        * GET -- tworzy formularz do edytowania swoich danych
        * POST -- sprawdza poprawność danych i zapisuje je w bazie

    :returns: jeśli podane dane są poprawne do generuje stronę do edycji danych,
              jeśli dane są niepoprawne to wskazuje błędne pola

    .. include:: ../source/login_required.rst

    """
    if request.method == 'GET':
        form = EditProfileForm(initial={
        'first_name': request.user.first_name,
        'last_name': request.user.last_name,
        'email': request.user.email })
    elif request.method == 'POST':
        form = EditProfileForm(request.POST)
        if form.is_valid():
            user = request.user
            user.first_name = form.cleaned_data['first_name']
            user.last_name = form.cleaned_data['last_name']
            user.email = form.cleaned_data['email']
            if form.cleaned_data['password']:
                user.set_password(form.cleaned_data['password'])
            user.save()
            messages.success(request, UPDATED)
    return direct_to_template(request, 'profiles/edit.html', locals())
开发者ID:lukaszsliwa,项目名称:Mapy,代码行数:29,代码来源:views.py

示例11: edit_profile

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,代码行数:33,代码来源:views.py

示例12: editProfile

def editProfile(request):
	if request.method == 'POST': # If the form has been submitted...
		form = EditProfileForm(request.POST) # A form bound to the POST data
		# assume that we have done the validation on the client side
		if(form.is_valid()):
			print "here?"
			messages.success(request, 'Your new profile information was saved')
			# get form data
			email = form.cleaned_data['email']
			password = form.cleaned_data['password']
			first_name = form.cleaned_data['first_name']
			last_name = form.cleaned_data['last_name']
			# get user object and then bind data to user
			user = User.objects.get(id__iexact=request.session['user_id'])
			user.first_name = first_name
			user.last_name = last_name
			user.email = email
			user.password = make_password(password)
			user.save()
			request.session['user_id'] = user.id
			request.session['first_name'] = user.first_name
			request.session['last_name'] = user.last_name
			request.session['email'] = email
			return HttpResponseRedirect('/home/profile') # Redirect after POST
	return HttpResponseRedirect('/error')
开发者ID:ZihaoAllen,项目名称:Frinder-Web,代码行数:25,代码来源:views.py

示例13: edit_profile

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,代码行数:25,代码来源:views.py

示例14: test_edit_profile_form

 def test_edit_profile_form(self):
     epf = EditProfileForm({
         'first_name': 'Jan',
         'last_name': 'Kowalski',
         'email': '[email protected]',
         })
     self.assertTrue(epf.is_valid(), 'Niepoprawny formularz.')
     self.assertFalse(EditProfileForm().is_valid(), 'Niepoprawny formularz.')
开发者ID:lukaszsliwa,项目名称:Mapy,代码行数:8,代码来源:tests.py

示例15: edit_profile

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,代码行数:9,代码来源:views.py


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