def blog_create(group_id): group = Group.get(group_id) if request.method == 'POST': title = request.form['blog_title'] content = request.form['blog_content'] id = Blog.create(title, content, get_user().id, group_id) if not id: return header_render('blog_create.html', group = group) return redirect(url_for('blog_show',blog_id = id)) else: return header_render('blog_create.html', group = group)
def create(): data = request.form new_blog = Blog.create(parent_user=data['user_id'], desc=data['desc'], title=data['title']) new_blog.save() result = jsonify({'status': True, 'data': new_blog.as_dict()}) return result
def create(): form = BlogForm() if form.validate_on_submit(): try: blog = Blog.create(blog_id=uuid.uuid4(), name=form.name.data, url=form.url.data, description=form.description.data) flash(u'创建 {name} 成功'.format(name=blog.name)) except IntegrityError: flash(u'创建 {name} 失败,该条目已存在'.format(name=form.name.data), 'error') else: flash(u'创建失败,参数错误', 'error') return redirect('/manage')