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


Python Organization.put_attachment方法代码示例

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


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

示例1: register_org

# 需要导入模块: from corehq.apps.orgs.models import Organization [as 别名]
# 或者: from corehq.apps.orgs.models.Organization import put_attachment [as 别名]
def register_org(request, template="registration/org_request.html"):
    referer_url = request.GET.get('referer', '')
    if request.method == "POST":
        form = OrganizationRegistrationForm(request.POST, request.FILES)
        if form.is_valid():
            name = form.cleaned_data["org_name"]
            title = form.cleaned_data["org_title"]
            email = form.cleaned_data["email"]
            url = form.cleaned_data["url"]
            location = form.cleaned_data["location"]
            logo = form.cleaned_data["logo"]
            if logo:
                logo_filename = logo.name
            else:
                logo_filename = ''

            org = Organization(name=name, title=title, location=location, email=email, url=url, logo_filename=logo_filename)
            org.save()
            if logo:
                org.put_attachment(content=logo.read(), name=logo.name)

            if referer_url:
                return redirect(referer_url)
            return HttpResponseRedirect(reverse("orgs_landing", args=[name]))
    else:
        form = OrganizationRegistrationForm() # An unbound form

    vals = dict(form=form)
    return render_to_response(request, template, vals)
开发者ID:mchampanis,项目名称:core-hq,代码行数:31,代码来源:views.py


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