def index(): form = UeditorForm() if form.validate_on_submit(): content_data = Content(title='test1', content=form.editor1.data) db.session.add(content_data) db.session.commit() return render_template('edit/editor.html',form=form, editor1=form.editor1.data)
def index(): form = UeditorForm() if form.validate_on_submit(): content_data = Content(title='test1', content=form.editor1.data) db.session.add(content_data) db.session.commit() return render_template('edit/editor.html', form=form, editor1=form.editor1.data)
def add_content(): form = UeditorForm() # tm = time.strftime("%Y-%m-%d %H:%M:%S") # print '%s ' % tm form.pub_time.data = time if form.validate_on_submit(): content =Content(title=form.title.data,content=form.editor1.data, editor=form.edit.data) db.session.add(content) db.session.commit() return redirect(url_for('admin.update_content',id=content.id)) return render_template('content/content.html',form=form)
def get_content(id): print(id) form = UeditorForm() # content_data = Content.query.filter_by(id=id).first() content_data = Content.query.get(int(id)) if form.validate_on_submit(): content_data.content = form.editor1.data db.session.add(content_data) db.session.commit() else: form.editor1.data = content_data.content return render_template('edit/editor.html',form=form, editor1=form.editor1.data)
def add_content(): form = UeditorForm() # tm = time.strftime("%Y-%m-%d %H:%M:%S") # print '%s ' % tm form.pub_time.data = time if form.validate_on_submit(): content = Content(title=form.title.data, content=form.editor1.data, editor=form.edit.data) db.session.add(content) db.session.commit() return redirect(url_for('admin.update_content', id=content.id)) return render_template('content/content.html', form=form)
def get_content(id): print(id) form = UeditorForm() # content_data = Content.query.filter_by(id=id).first() content_data = Content.query.get(int(id)) if form.validate_on_submit(): content_data.content = form.editor1.data db.session.add(content_data) db.session.commit() else: form.editor1.data = content_data.content return render_template('edit/editor.html', form=form, editor1=form.editor1.data)
def update_content(id): form = UeditorForm() content = Content.query.get(int(id)) if form.validate_on_submit(): content.content = form.editor1.data content.title = form.title.data content.pub_time = form.pub_time.data content.editor = form.edit.data db.session.add(content) db.session.commit() else: form.editor1.data = content.content form.title.data = content.title form.pub_time.data = content.pub_time form.edit.data = content.editor return render_template('content/content.html',form=form)
def update_content(id): form = UeditorForm() content = Content.query.get(int(id)) if form.validate_on_submit(): content.content = form.editor1.data content.title = form.title.data content.pub_time = form.pub_time.data content.editor = form.edit.data db.session.add(content) db.session.commit() else: form.editor1.data = content.content form.title.data = content.title form.pub_time.data = content.pub_time form.edit.data = content.editor return render_template('content/content.html', form=form)