views.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:NZ-ORCID-Hub 作者: Royal-Society-of-New-Zealand 项目源码 文件源码
def logo():
    """Manage organisation 'logo'."""
    org = current_user.organisation
    best = request.accept_mimetypes.best_match(["text/html", "image/*"])
    if best == "image/*" and org.logo:
        return send_file(
            BytesIO(org.logo.data),
            mimetype=org.logo.mimetype,
            attachment_filename=org.logo.filename)

    form = LogoForm()
    if form.validate_on_submit():
        f = form.logo.data
        filename = secure_filename(f.filename)
        logo = File.create(data=f.read(), mimetype=f.mimetype, filename=f.filename)
        org.logo = logo
        org.save()
        flash(f"Saved organisation logo '{filename}'", "info")

    return render_template("logo.html", form=form)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号