def setting(): if request.method == 'GET': form = SettingForm() return render_template("setting.html", form=form) else: form = SettingForm(request.form) pass
def settings(): errors = None admin_settings = get_settings( g.db, admin_id=current_user.admin_id) or Setting() form = SettingForm(request.form) if request.method == 'POST': if form.validate(): already_completed = finished_setting(admin_settings) form.populate_obj(admin_settings) admin_settings.admin_id = current_user.admin_id g.db.session.add(admin_settings) g.db.session.commit() url = 'hunts' if already_completed else 'new_hunt' flash('Settings have been updated successfully', 'success') return make_response(redirect(url_for(url))) else: logger.info( '%s attempted to submit settings information' ' resulting in errors: %s', current_user.email, form.errors) return make_response(render_template( 'settings.html', login=admin_settings.login, form=form, password=admin_settings.password, wax_site=admin_settings.wax_site ))
def settings(): errors = None admin_settings = get_settings(g.db, admin_id=current_user.admin_id) or Setting() form = SettingForm(request.form) if request.method == 'POST': if form.validate(): already_completed = finished_setting(admin_settings) form.populate_obj(admin_settings) admin_settings.admin_id = current_user.admin_id g.db.session.add(admin_settings) g.db.session.commit() url = 'hunts' if already_completed else 'new_hunt' flash('Settings have been updated successfully', 'success') return make_response(redirect(url_for(url))) else: logger.info( '%s attempted to submit settings information' ' resulting in errors: %s', current_user.email, form.errors) return make_response( render_template('settings.html', login=admin_settings.login, form=form, password=admin_settings.password, wax_site=admin_settings.wax_site))
def setting(request): if request.method == 'POST': form = SettingForm(data=request.POST, instance=request.user.get_profile()) if form.is_valid(): form.save() return HttpResponseRedirect("/") else: print 'Not valid!!!' else: form = SettingForm(instance=request.user.get_profile()) tmpl = 'settingContent_emb.html' if request.is_ajax() else 'setting.html' from django.shortcuts import render_to_response return render_to_response(tmpl, {'form':form, 'req_usr':request.user})
def settings(): form = SettingForm() if form.validate_on_submit(): current_user.name = form.name.data current_user.blog_title = form.blog_title.data current_user.blog_sub_title = form.blog_sub_title.data current_user.about = form.about.data db.session.commit() flash('设置已更新', 'success') return redirect(url_for('blog.index')) form.name.data = current_user.name form.blog_title.data = current_user.blog_title form.blog_sub_title.data = current_user.blog_sub_title form.about.data = current_user.about return render_template('admin/settings.html', form=form)
class settings: crumb = Crumb() def __init__(self): self.setting_form = SettingForm ( ) self.pass_form = user_model ( ).pass_form if session.user_id is None: raise web.SeeOther('/login?next=/settings') def GET(self): self.crumb.append('设置') user = user_model().get_one({'id':session.user_id}) self.setting_form.name.set_value(user.name) self.setting_form.email.set_value(user.email) self.setting_form.signature.set_value(user.signature) self.setting_form.outsite_link.set_value(user.outsite_link) return render.settings('设置', user, self.setting_form, self.pass_form, self.crumb.output()) def POST(self): self.crumb.append('设置') user = user_model().get_one({'id':session.user_id}) self.setting_form.name.set_value(user.name) if not self.setting_form.validates(): self.setting_form.name.set_value(user.name) self.setting_form.email.set_value(user.email) self.setting_form.email.set_value(user.signature) self.setting_form.email.set_value(user.outsite_link) return render.settings('设置', user, self.setting_form, self.pass_form, self.crumb.output()) else: user_model().update({'id':user.id}, {'email':self.setting_form.d.email, 'signature':self.setting_form.d.signature, 'outsite_link':self.setting_form.d.outsite_link.replace('http://', '').replace('https://', '')}) self.crumb.clear() raise web.SeeOther('/settings')
def post(self): user = self.current_user form = SettingForm.init(user=user, args=self.request.arguments) if form.validate(): user = form.save(user) return self.redirect_next_url() return self.render("user/setting.html", form=form)
def settings(): settingform = SettingForm() if settingform.validate_on_submit(): setup["pDiff"] = settingform.diff.data setup["pName"] = settingform.name.data if settingform.diff.data == "easy": setup["pCredits"] = 1000 setup["pSPLimit"] = 16 if settingform.diff.data == "med": setup["pCredits"] = 800 setup["pSPLimit"] = 14 if settingform.diff.data == "hard": setup["pCredits"] = 500 setup["pSPLimit"] = 12 return redirect(url_for("skillpoints")) return render_template("settings.html", form=settingform)
def setting(): form=SettingForm() print(request.args) if request.method=='POST': appname = request.form.get('appname') serveraddr = request.form.get('serveraddr') rtmpaddr = request.form.get('rtmpaddr') controller = request.form.get('controller') module = request.form.get('module') tmp = Tmp.query.filter_by(user_id=current_user.id).first() if tmp is None: device=Tmp(user_id=current_user.id,appname=appname,serveraddr=serveraddr,rtmpaddr=rtmpaddr,controller=controller,module=module) db.session.add(device) db.session.commit() else: tmp.appname=appname tmp.serveraddr=serveraddr tmp.rtmpaddr=rtmpaddr tmp.controller=controller tmp.module=module db.session.commit() data = [{ 'username', 'abc', 'age', 18 }, { 'username', 'abc', 'age', 18 }, { 'username', 'abc', 'age', 18 } ] return render_template('index.html', form=form, data=data)
def admins(): if request.method == 'POST': form = AdminForm(request.form) if form.validate(): admin = Admin() form.populate_obj(admin) admin.pw_hash = bcrypt.generate_password_hash(form.password.data) g.db.session.add(admin) g.db.session.commit() login_user(get_admin(g.db, admin.email)) flash('Welcome to xAPI Scavenger Hunt', 'success') logger.info( 'Admin registration form was submitted successfully for %s', admin.email) return make_response( render_template('settings.html', form=SettingForm())) logger.info( 'Admin registration form was submitted with' ' invalid information. Errors: %s', form.errors) flash( 'There was an error creating your admin profile.' ' Please try again.', 'warning') return render_template('homepage.html', form=form, display_login_link=True) return login()
def settings(): user = session['user'] logged_in = True form = SettingForm() freq_data = posts.get_word_freq_dict() return render_template('settings.html', user=user, logged_in=logged_in, form=form, freq_data=freq_data)
def get(self): action = self.get_argument("action", None) if action: if action == 'reset_head': self.current_user.reset_img('head') result = {"status": "success", "message": "头部背景已重置"} elif action == 'reset_bg': self.current_user.reset_img('background') result = {"status": "success", "message": "背景已重置"} return self.send_result(result, '/account/setting') user = self.current_user form = SettingForm.init(user) return self.render("user/setting.html", form=form)
def get(self): action = self.get_argument("action", None) if action == 'reset_head': self.current_user.head_img = '' result = {"status": "success", "message": "头部背景已重置"} if self.is_ajax: self.write(result) else: self.flash_message(result) self.redirect('/account/setting') return user = self.current_user form = SettingForm.init(user) return self.render("user/setting.html", form=form)
def Setting(): if request.method == "GET": form = SettingForm() return render_template('settings.html', form=form)
def __init__(self): self.setting_form = SettingForm ( ) self.pass_form = user_model ( ).pass_form if session.user_id is None: raise web.SeeOther('/login?next=/settings')
def index(): form = SettingForm() datas=TmpData.query.filter_by(user_id=current_user.id).all() print(datas) return render_template('index.html',form=form,data=datas)
def get(self): user = self.current_user form = SettingForm.init(user) return self.render("user/setting.html", form=form)