本文整理汇总了Python中models.Article.abstract方法的典型用法代码示例。如果您正苦于以下问题:Python Article.abstract方法的具体用法?Python Article.abstract怎么用?Python Article.abstract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Article
的用法示例。
在下文中一共展示了Article.abstract方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import abstract [as 别名]
def create():
csrf_token = request.form.get('csrf_token')
upload_folder = os.path.join(app.config['UPLOAD_FOLDER'], mod.name, csrf_token, 'files')
form = RegistrationForm()
if not os.path.exists(upload_folder):
flash(u'Selecione o arquivo do artigo para enviá-lo.', 'danger')
return render_template('scholar/new.html', form=form)
if form.validate() is False:
return render_template('scholar/new.html', form=form)
else:
article = Article()
article.title = form.title.data
article.theme = form.theme.data
article.abstract = form.abstract.data
article.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
article.approval_status = 0
author_input_list = form.authors.data.split(',')
for author_input in author_input_list:
article.authors.append(AuthorScholar(author_input))
keyword_input_list = form.keywords.data.split(',')
for keyword_input in keyword_input_list:
keyword = KeyWord.query.filter_by(name=keyword_input).first()
if not keyword:
article.keywords.append(KeyWord(keyword_input))
else:
article.keywords.append(keyword)
db.session.add(article)
db.session.flush()
if os.path.exists(upload_folder):
file_name = [file for file in os.listdir(upload_folder)][0]
article.url = upload_helper.upload_s3_file(
os.path.join(upload_folder, file_name),
os.path.join('scholar/', str(article.id), 'files/', 'article'),
{
'ContentType': "application/pdf",
'ContentDisposition': 'attachment; filename=dataviva-article-' + str(article.id) + '.pdf'
}
)
shutil.rmtree(os.path.split(upload_folder)[0])
db.session.commit()
message = u'Muito obrigado! Seu estudo foi submetido com sucesso e será analisado pela equipe do DataViva. \
Em até 15 dias você receberá um retorno sobre sua publicação no site!'
flash(message, 'success')
return redirect(url_for('scholar.index'))
示例2: create
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import abstract [as 别名]
def create():
csrf_token = request.form.get('csrf_token')
upload_folder = os.path.join(app.config['UPLOAD_FOLDER'], mod.name, csrf_token, 'files')
form = RegistrationForm()
if not os.path.exists(upload_folder):
flash(u'Selecione o arquivo do artigo para enviá-lo.', 'danger')
return render_template('scholar/new.html', form=form)
if form.validate() is False:
form.set_choices(approved_articles_keywords())
return render_template('scholar/new.html', form=form)
else:
article = Article()
article.title = form.title.data
article.theme = form.theme.data
article.abstract = form.abstract.data
article.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
article.approval_status = 0
author_input_list = form.authors.data.replace(', ', ',').split(',')
for author_input in author_input_list:
article.authors.append(AuthorScholar(author_input))
for keyword_input in form.keywords.data:
keyword = KeyWord.query.filter_by(name=keyword_input).first()
if not keyword:
article.keywords.append(KeyWord(keyword_input))
else:
article.keywords.append(keyword)
db.session.add(article)
db.session.flush()
if os.path.exists(upload_folder):
file_name = [file for file in os.listdir(upload_folder)][0]
article.file_url = upload_helper.upload_s3_file(
os.path.join(upload_folder, file_name),
os.path.join('scholar/', str(article.id), 'files/', 'article'),
{
'ContentType': "application/pdf",
'ContentDisposition': 'attachment; filename=dataviva-article-' + str(article.id) + '.pdf'
}
)
shutil.rmtree(os.path.split(upload_folder)[0])
db.session.commit()
upload_helper.log_operation(module=mod.name, operation='create', user=(g.user.id, g.user.email), objs=[(article.id, article.title)])
new_article_advise(article, request.url_root)
message = dictionary()["article_submission"]
flash(message, 'success')
return redirect(url_for('scholar.index'))
示例3: __save_blog
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import abstract [as 别名]
def __save_blog(title, abstract, body, category_id, tag_names, article_id=None):
tags = []
for tag_name in tag_names.split(','):
tag, is_create = Tag.objects.get_or_create(name=tag_name)
tags.append(tag)
category = Category.objects.filter(id=category_id)[0]
if article_id is None:
article = Article(title=title, abstract=abstract, body=body, category=category)
else:
article = Article.objects.filter(id=article_id)[0]
article.title = title
article.abstract = abstract
article.body = body
article.category = category
article.save()
print dir(article)
article.tag.clear()
article.tag.add(*tags)
return article.id