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