本文整理汇总了Python中models.Article.postage_date方法的典型用法代码示例。如果您正苦于以下问题:Python Article.postage_date方法的具体用法?Python Article.postage_date怎么用?Python Article.postage_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Article
的用法示例。
在下文中一共展示了Article.postage_date方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import postage_date [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 postage_date [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'))