def edit_article(article_id): a = Article.find(article_id) cookie = token_cookie() template = render_template( "article/edit_article.html", article=a, token=cookie['token'], ) r = make_response(template) r.set_cookie(cookie['token'], cookie['id'], max_age=1200) return r
def detailData(self, iKwargs): article = ArticleModel.find({'mk': iKwargs['mk']}) if article.get('updateDate', '') == '': updateDate = article.get('createDate', '')[:10] else: updateDate = article.get('updateDate', '')[:10] data = { 'id': str(article.get('_id', '')), 'mk': article.get('mk', ''), 'title': article.get('title', ''), 'content': article.get('content', ''), 'summary': article.get('summary', ''), 'createYear': article.get('createDate', '')[:4], 'createDay': article.get('createDate', '')[5:10], 'createDate': article.get('createDate', ''), 'updateDate': updateDate, 'category': article.get('category', ''), 'tag': article.get('tag', '') } return data
def put(self): iKwargs = request.form.to_dict() updateDate = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) article = ArticleModel.find({'mk': iKwargs['mk']}) def exit(args): if args in iKwargs: article.set(args, iKwargs[args]) exit('content') exit('summary') exit('title') article.set('updateDate', updateDate) article.save() data = { 'title': article.get('title', ''), 'summary': article.get('summary', ''), 'content': article.get('content', ''), 'updateDate': article.get('updateDate', ''), 'createDate': article.get('createDate', ''), 'mk': article.get('mk', '') } return data
def article_detail(id): a = Article.find(id) if a is None: abort(404) return render_template('article.html', article=a)