当前位置: 首页>>代码示例>>Python>>正文


Python Article.approval_status方法代码示例

本文整理汇总了Python中models.Article.approval_status方法的典型用法代码示例。如果您正苦于以下问题:Python Article.approval_status方法的具体用法?Python Article.approval_status怎么用?Python Article.approval_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Article的用法示例。


在下文中一共展示了Article.approval_status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import approval_status [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'))
开发者ID:aromeira,项目名称:dataviva-site,代码行数:59,代码来源:views.py

示例2: create

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import approval_status [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'))
开发者ID:DataViva,项目名称:dataviva-site,代码行数:58,代码来源:views.py


注:本文中的models.Article.approval_status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。