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


Python File.approved方法代码示例

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


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

示例1: save_file

# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import approved [as 别名]
def save_file(uploaded_file, release_id):
    if uploaded_file: # and allowed_file(uploaded_file.filename):
        filename = secure_filename(uploaded_file.filename)
        if os.path.isfile(os.path.join(app.config['UPLOAD_FOLDER'], filename)):
            fileName, fileExtension = os.path.splitext(filename)
            filename = fileName + '-' + time.strftime("%Y%m%d-%H%M%S") + fileExtension
        uploaded_file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

        description = "";
        statinfo = os.stat(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        file = File(release_id=release_id, filename=filename, description=description, size=statinfo.st_size)
        file.approved = False;
        db.session.add(file)
        db.session.commit()
开发者ID:renpy,项目名称:vn-list,代码行数:16,代码来源:views.py

示例2: upload_file_old

# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import approved [as 别名]
def upload_file_old(game_slug):
    release_id = request.args.get('release', None)
    file_id = request.args.get('file', None)

    if file_id:
        file = db.session.query(File).filter(File.id==file_id).one()
        form = UploadForm()
        form.edit.data = "True"
    else:
        form = UploadForm()
        form.edit.data = ""

    if form.validate_on_submit():
        uploaded_file = form.uploaded_file.data
        if uploaded_file: # and allowed_file(uploaded_file.filename):
            filename = secure_filename(uploaded_file.filename)
            if os.path.isfile(os.path.join(app.config['UPLOAD_FOLDER'], filename)):
                fileName, fileExtension = os.path.splitext(filename)
                filename = fileName + '-' + time.strftime("%Y%m%d-%H%M%S") + fileExtension
            uploaded_file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

        if form.edit.data:
            if uploaded_file:
                file.filename=filename

            file.description=form.description.data
        else:
            if uploaded_file:
#                release = Release.query.filter(Release.id==release_id).one()
                file = File(release_id=release_id, filename=filename, description=form.description.data)
                db.session.add(file)
        if uploaded_file or form.edit.data:
            file.approved = False;
            db.session.commit()
            if not form.edit.data:
                form.description.data=None
        if form.edit.data:
            flash('File changed!')
        else:
            if uploaded_file:
                flash('File uploaded!')
    else:
        if form.edit.data:
            form.description.data=file.description

    return render_template('add_file.html', form=form, site_data=site_data(), navigation=return_navigation())
开发者ID:renpy,项目名称:vn-list,代码行数:48,代码来源:views.py


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