def settings(): blog = Blog.getone() if blog is None: blog = {}.fromkeys(Blog.get_fields(), '') flashx.warning('You have no settings, please eidt and save') return render_template('settings.html', active_tab='settings', blog=blog)
def update_settings(): name = request.form['name'] description = request.form['description'] disqus = request.form['disqus'] blog = Blog.getone() if blog is None: # insert blog = Blog.create(name=name, description=description, disqus=disqus) flashx.success('Create settings successfully') else: # update blog.name = name blog.disqus = disqus blog.description = description blog.save() flashx.success('Save settings successfully') return redirect(url_for('settings'))