def home(): form = InfoForm() if form.is_submitted(): print(type(form.latitude.data)) print(type(form.longtitude.data)) print(type(form.phonenumber.data)) yelp(form.latitude.data, form.longtitude.data, form.phonenumber.data) return render_template('Ehop.html', form=form)
def addInfo(id): print(id) form = InfoForm() if request.method == 'POST' and form.validate_on_submit(): servings = form.servings.data cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor) cursor.execute('call setserving(%s,%s) ',(id,servings)) mysql.connection.commit() return redirect(url_for('userPlans')) return render_template('addInfo.html',form=form,id=id)
def inform(): form = InfoForm() if form.validate_on_submit(): info = Info(Infotitle=form.infotitle.data) db.session.add(info) db.session.commit() flash('Congratulations, the infomation has been added!') #info=Info.query.filter_by(Infotitle=form.infotitle.data).first() rows = Info.query.count() url = './Info/info' + str(rows) + '.txt' save_to_file(url, form.infocontent.data) return redirect(url_for('index')) return render_template('inform.html', title='Information', form=form)
def info(): form = InfoForm() if 'email' not in session: flash('请先登录!','warning') return redirect(url_for('.a')) email=session['email'] t_user=Users.query.filter_by(email=email).first() form.username.data=t_user.username form.name.data=t_user.name form.idcard.data=t_user.idcard form.phone.data=t_user.phone form.province.data=t_user.province form.address.data=t_user.address if form.validate_on_submit(): Users.query.filter_by(email=email).update({'name':form.name.data},{'username':form.username.data}, {'idcard':form.idcard.data},{'province':form.province.data}, {'phone':form.phone.data},{'address':form.address.data}) flash(f'个人信息更新成功','success') return redirect(url_for('.home')) return render_template('info.html', title='Info', form=form)
def profile(request): """ View for profile returns profile.html template """ if request.user.is_authenticated(): context_dict={} profile = UserID.objects.get(user=request.user) info_form = InfoForm(instance=request.user) orginfo_form = OrgInfoForm(instance=profile) form = PasswordChangeForm(request.user) context_dict["form"] = form context_dict["info_form"] = info_form context_dict["orginfo_form"] = orginfo_form if request.method == 'POST': if "saveinfo" in request.POST : info_form = InfoForm(request.POST,instance=request.user) orginfo_form = OrgInfoForm(request.POST,instance=profile) if info_form.is_valid() and orginfo_form.is_valid(): form1 = info_form.save() form2 = orginfo_form.save() context_dict["success"] = "Details Successfully Updated" return render(request, 'app/profile.html',context_dict ) else : context_dict["error"] = "Error changing details " + str(info_form.errors) + str(orginfo_form.errors) return render(request, 'app/profile.html',context_dict,status=400 ) if "changepwd" in request.POST: form = PasswordChangeForm(request.user, request.POST) if form.is_valid(): user = form.save() update_session_auth_hash(request, user) # Important! context_dict["success"] = 'Your password was successfully updated!' return render(request, 'app/profile.html',context_dict ) else: context_dict["error"] = form.errors return render(request, 'app/profile.html',context_dict,status=400 ) else : context_dict["error"] = "Invalid request." return render(request, 'app/profile.html',context_dict,status=404 ) else: return render(request, 'app/profile.html',context_dict ) else: return HttpResponseRedirect(settings.LOGIN_URL)
def home(): form = InfoForm() return render_template("index.html", title='UWaterloo Demo', form=form)