def post(self): if self.group != '1': self.render("404.html", username=self.username, group=self.group) arguments = { "page_size": self.get_argument("pagesize"), "status_name": self.get_argument("statusname"), "group_name": self.get_argument("groupname"), "type_name": self.get_argument("typename"), } settings = get_settings(self.session) form = SettingsForm(self.request.arguments) update_error = settings_update_validation(self.session) if form.validate(): if update_error == "": update_settings(self.session, settings, arguments) self.redirect("/admin/settings") else: self.render("/admin/settings.html", username=self.username, group=self.group, settings=settings, form=form, db_error=update_error) else: self.render("/admin/settings.html", username=self.username, group=self.group, settings=settings, form=form, db_error=None)
def settings(): form = SettingsForm(request.form) if request.method == 'GET': config = configparser.ConfigParser() config.read('config.ini') form.image_path.data = config['DEFAULT']['IMAGE_PATH'] form.suspected_user.data = config['DEFAULT']['SUSPECTED_USER'] form.classified_folder.data = config['DEFAULT']['CLASSIFIED_DATA_FOLDER'] form.es_host.data = config['ELASTIC_SEARCH']['HOST'] form.es_port.data = config['ELASTIC_SEARCH']['PORT'] form.regripper_path.data = config['3RD_PARTY']['REGRIPPER_PATH'] form.virustotal_api_key.data = config['3RD_PARTY']['VIRUSTOTAL_API_KEY'] form.webshrinker_api_key.data = config['3RD_PARTY']['WEBSHRINKER_API_KEY'] form.webshrinker_api_secret.data = config['3RD_PARTY']['WEBSHRINKER_API_SECRET'] if request.method == 'POST' and form.validate(): config = configparser.ConfigParser() config['DEFAULT'] = {} config['DEFAULT']['IMAGE_PATH'] = form.image_path.data config['DEFAULT']["SUSPECTED_USER"] = form.suspected_user.data config['DEFAULT']["CLASSIFIED_DATA_FOLDER"] = form.classified_folder.data config['ELASTIC_SEARCH'] = {} config['ELASTIC_SEARCH']['HOST'] = form.es_host.data config['ELASTIC_SEARCH']['PORT'] = form.es_port.data config['3RD_PARTY'] = {} config['3RD_PARTY']["REGRIPPER_PATH"] = form.regripper_path.data config['3RD_PARTY']["VIRUSTOTAL_API_KEY"] = form.virustotal_api_key.data config['3RD_PARTY']["WEBSHRINKER_API_KEY"] = form.webshrinker_api_key.data config['3RD_PARTY']["WEBSHRINKER_API_SECRET"] = form.webshrinker_api_secret.data with open('config.ini', 'w') as configfile: config.write(configfile) return redirect('/') return render_template('settings.html', title='Settings', form=form)
def settings(): hasKey = False form = SettingsForm(request.form) if 'redcap_api_key' in session: flash('REDcap API key entered successfully!', "info") hasKey = True theKey = session['redcap_api_key'] if (request.method == 'POST' and form.validate()): session['redcap_api_key'] = form.redcap_api_key.data theKey = session['redcap_api_key'] return render_template('settings.html', form=form, hasKey=hasKey, key=theKey, proj_data=getProjInfo(theKey)) else: flash("Please enter your REDCap API key.", "info") if request.method == 'POST' and form.validate(): session['redcap_api_key'] = form.redcap_api_key.data flash('REDcap API key entered successfully!', "success") return redirect(url_for('home')) return render_template('settings.html', form=form, hasKey=hasKey)
def settings(): """ HR个人信息设置页面 :return: """ if request.method == 'GET': return render_template('settings.html') else: form = SettingsForm(request.form) if form.validate(): username = form.username.data email = form.email.data user = HrUser.query.get(g.user.id) user.username = username user.email = email db.session.commit() return restful.success() else: return restful.params_error(message=form.get_error())
def security(): setting = Settings.query.get(1) pair_choices = [(i.name, i.name) for i in Symbol.query.all()] form = SettingsForm(obj=setting) form.allowed_pairs.choices = pair_choices if request.method == 'POST': form = SettingsForm(request.form) form.allowed_pairs.choices = pair_choices if form.validate(): setting.allowed_pairs = form.allowed_pairs.data setting.allowed_actions = form.allowed_actions.data setting.allowed_balance = form.allowed_balance.data setting.test_mode = form.test_mode.data db_session.commit() flash('Settings have been updated.', 'success') return redirect(url_for('dashboard')) return render_template('security.html', form=form)
def post(self): if self.group != '1': self.render("404.html", username=self.username, group=self.group) arguments = { "page_size": self.get_argument("pagesize"), "status_name": self.get_argument("statusname"), "group_name": self.get_argument("groupname"), "type_name": self.get_argument("typename"), } settings = get_settings(self.session) form = SettingsForm(self.request.arguments) update_error = settings_update_validation(self.session) if form.validate(): if update_error == "": update_settings(self.session, settings, arguments) self.redirect("/admin/settings") else: self.render( "/admin/settings.html", username = self.username, group = self.group, settings = settings, form = form, db_error = update_error ) else: self.render( "/admin/settings.html", username = self.username, group = self.group, settings = settings, form = form, db_error = None )
def user_settings(): """User settings""" user = session["user"] form = SettingsForm(email=user.email) if request.method == "POST" and form.validate(): user_changed = False if request.form["email"] and request.form["email"] != user.email: user.email = request.form["email"] user_changed = True flash("Email address saved!") if request.form["password"]: user.set_password(request.form["password"]) user_changed = True user.save() flash("Your password was successfully changed!") if user_changed: user.save() return redirect(url_for("page")) return render_template("settings.html", form=form)
def settings(): if 'user_name' in session: user = UserDB.query.filter_by( nickname=session.get('user_name', None)).first() elif username is not None: user = UserDB.query.filter_by(nickname=username).first() form = SettingsForm() intol = Intolerences.query.filter_by(uid=user.uid) intolerences = '' for key in intol: intolerences = key.intolerencename + ' ' + intolerences session['intolerences'] = intolerences if request.method == 'POST': if form.validate() == False: return render_template('settings.html', form=form, response={ 'user_info': { 'birthdate': user.birthdate, 'weight': user.weight, 'height': user.height, 'gender': user.gender, 'activitylevel': user.activitylevel, 'diet': user.diet, 'intolerances': intolerences } }) else: if request.form.get("weightunit") == "lbs": user.weight = form.weight.data / 2.20462 else: user.weight = form.weight.data if request.form.get("heightunit") == "in": user.height = form.height.data / 0.393701 else: user.height = form.height.data birthdate = form.birth_date.data activitylevel = form.activity_level.data diet = form.diet.data gender = form.gender.data print gender for key in intol: db.session.delete(key) db.session.commit() intolerences_data = form.intolerences.data intolerences = '' for key in intolerences_data: intol_temp = Intolerences(user.uid, key) db.session.add(intol_temp) db.session.commit() intolerences = intolerences + ' ' + key print intolerences user.birthdate = form.birth_date.data user.activitylevel = form.activity_level.data user.diet = form.diet.data user.gender = form.gender.data #intol.intolerencename = session.get('intolerences') db.session.commit() return redirect(url_for('profile')) elif request.method == 'GET': return render_template('settings.html', form=form, response={ 'user_info': { 'birthdate': user.birthdate, 'weight': user.weight, 'height': user.height, 'gender': user.gender, 'activitylevel': user.activitylevel, 'diet': user.diet, 'intolerances': intolerences } })
def settings(): form = SettingsForm(request.form) if request.method == 'POST': form = SettingsForm(request.form) if form.validate(): uchanged = False pchanged = False user = current_user profile = user.profile if user.username != form.username.data: user.username = form.username.data if user.modify_chance <= 0: form.username.errors.append(u'您修改用户名的机会已经用完,无法再修改用户名!') return render_template("settings.html", form=form) if User.query.filter( User.username == form.username.data).first(): form.username.errors.append(u'该用户名已被使用!') return render_template("settings.html", form=form) uchanged = True user.modify_chance -= 1 if user.modify_chance <= 0: user.modify_chance = 0 form.username.extra_class = "disable" #if user.nickname != form.nickname.data: # user.nickname = form.nickname.data # uchanged =True if profile.city != form.city.data or\ profile.province != form.province.data or\ profile.birthday != form.birthday.data or\ profile.blog != form.blog.data or\ profile.descp != form.descp.data or\ profile.signature != form.signature.data or \ profile.realname != form.realname.data or\ profile.idcard != form.idcard.data: profile.city = form.city.data profile.province = form.province.data profile.birthday = form.birthday.data profile.blog = form.blog.data profile.descp = form.descp.data profile.signature = form.signature.data profile.realname = form.realname.data profile.idcard = form.idcard.data pchanged = True if uchanged: db.session.add(user) if pchanged: db.session.add(profile) if uchanged or pchanged: db.session.commit() if uchanged: mcache_set(str(user.id), user) login_user(user, remember=True) #return redirect("/") else: flash(u"个人资料设置成功!") return render_template("settings.html", form=form) form = settings_from_user(current_user) return render_template("settings.html", form=form)
def settings(): form = SettingsForm(request.form) if request.method == "POST": form = SettingsForm(request.form) if form.validate(): uchanged = False pchanged = False user = current_user profile = user.profile if user.username != form.username.data: user.username = form.username.data if user.modify_chance <= 0: form.username.errors.append(u"您修改用户名的机会已经用完,无法再修改用户名!") return render_template("settings.html", form=form) if User.query.filter(User.username == form.username.data).first(): form.username.errors.append(u"该用户名已被使用!") return render_template("settings.html", form=form) uchanged = True user.modify_chance -= 1 if user.modify_chance <= 0: user.modify_chance = 0 form.username.extra_class = "disable" # if user.nickname != form.nickname.data: # user.nickname = form.nickname.data # uchanged =True if ( profile.city != form.city.data or profile.province != form.province.data or profile.birthday != form.birthday.data or profile.blog != form.blog.data or profile.descp != form.descp.data or profile.signature != form.signature.data or profile.realname != form.realname.data or profile.idcard != form.idcard.data ): profile.city = form.city.data profile.province = form.province.data profile.birthday = form.birthday.data profile.blog = form.blog.data profile.descp = form.descp.data profile.signature = form.signature.data profile.realname = form.realname.data profile.idcard = form.idcard.data pchanged = True if uchanged: db.session.add(user) if pchanged: db.session.add(profile) if uchanged or pchanged: db.session.commit() if uchanged: mcache_set(str(user.id), user) login_user(user, remember=True) # return redirect("/") else: flash(u"个人资料设置成功!") return render_template("settings.html", form=form) form = settings_from_user(current_user) return render_template("settings.html", form=form)