本文整理汇总了Python中organization.Organization.save方法的典型用法代码示例。如果您正苦于以下问题:Python Organization.save方法的具体用法?Python Organization.save怎么用?Python Organization.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类organization.Organization
的用法示例。
在下文中一共展示了Organization.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AuthenticatedPost
# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import save [as 别名]
def AuthenticatedPost(self, org, _):
global_admin = False
local_admin = False
if org.name == GLOBAL_ADMIN_NAME:
global_admin = True
if org.is_admin == True and global_admin == False:
local_admin = True
if global_admin == False and local_admin == False:
self.redirect("/")
return
# create form
form = (
GlobalAdminCreateOrganizationForm(self.request.POST) if global_admin
else CreateOrganizationForm(self.request.POST)
)
events = self._get_events(org, global_admin, local_admin)
form.incident.choices = [(str(event.key().id()), event.name) for event in events]
if form.validate() and not form.errors:
# create new org
event = event_db.Event.get_by_id(int(form.incident.data))
new_org = Organization(
name=form.name.data,
)
new_org.incidents = [event.key()]
new_org.save()
del(form.incident)
del(form.incidents)
form.populate_obj(new_org)
new_org.save()
organization.PutAndCache(new_org)
# redirect to the add contact page
self.redirect('/admin-create-contact?selected_org=%d' % new_org.key().id())
else:
self.response.out.write(template.render({
"form": form,
"global_admin": global_admin,
}))