def new_site_setting(): form = SiteSettingForm() if form.validate_on_submit(): site_setting = SiteSetting() site_setting.name = form.name.data site_setting.value = form.value.data db.session.add(site_setting) flash('"{0}" has been saved'.format(site_setting.name)) return redirect(url_for('.site_settings')) return render_template("admin/site-settings/new.html", form=form)
def edit_site_setting(id): form = SiteSettingForm() site_setting = SiteSetting.query.filter_by(id=id).first() if(site_setting is None): abort(404) if form.validate_on_submit(): site_setting.value = form.value.data db.session.add(site_setting) flash('"{0}" has been saved'.format(site_setting.name)) return redirect(url_for('.site_settings')) form.name.data = site_setting.name form.value.data = site_setting.value return render_template("admin/site-settings/edit.html", form=form, \ setting=site_setting)