本文整理汇总了Python中portalpy.Portal.invitations方法的典型用法代码示例。如果您正苦于以下问题:Python Portal.invitations方法的具体用法?Python Portal.invitations怎么用?Python Portal.invitations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portalpy.Portal
的用法示例。
在下文中一共展示了Portal.invitations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: invite_org_user
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import invitations [as 别名]
def invite_org_user():
portal = Portal('http://wittakermathot.maps.arcgis.com', 'wmathot', '***')
# Prepare the invitations
invitations = [
{'fullname': 'James Bond', 'username': 'jbond_wittakermathot',
'email': '[email protected]', 'role': 'account_user'}]
# Invite users. Log those who werent invited
not_invited = portal.invite(invitations, 'test1', 'test2')
if not_invited:
print 'Not invited: ' + str(not_invited)
# Accept the invitations and set the user's password to their username
accepted_count = 0
for invitation in invitations:
username = invitation['username']
for pending_invitation in portal.invitations(['id', 'username']):
if username == pending_invitation['username']:
invitation_id = pending_invitation['id']
new_password = username
is_reset = portal.reset_user(username, invitation_id, new_password)
if is_reset:
portal_as_user = Portal('http://www.arcgis.com', username, new_password)
is_accepted = portal_as_user.accept(invitation_id)
if is_accepted:
accepted_count += 1
print 'Invited ' + str(len(invitations)) + ', Accepted ' + str(accepted_count)