本文整理汇总了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()
示例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())