本文整理汇总了Python中models.api_auth_access.ApiAuthAccess.expiration方法的典型用法代码示例。如果您正苦于以下问题:Python ApiAuthAccess.expiration方法的具体用法?Python ApiAuthAccess.expiration怎么用?Python ApiAuthAccess.expiration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.api_auth_access.ApiAuthAccess
的用法示例。
在下文中一共展示了ApiAuthAccess.expiration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.api_auth_access import ApiAuthAccess [as 别名]
# 或者: from models.api_auth_access.ApiAuthAccess import expiration [as 别名]
def post(self, auth_id):
self._require_admin()
auth = ApiAuthAccess.get_by_id(auth_id)
auth_types_enum = [AuthType.READ_API] if auth and AuthType.READ_API in auth.auth_types_enum else []
if self.request.get('allow_edit_teams'):
auth_types_enum.append(AuthType.EVENT_TEAMS)
if self.request.get('allow_edit_matches'):
auth_types_enum.append(AuthType.EVENT_MATCHES)
if self.request.get('allow_edit_rankings'):
auth_types_enum.append(AuthType.EVENT_RANKINGS)
if self.request.get('allow_edit_alliances'):
auth_types_enum.append(AuthType.EVENT_ALLIANCES)
if self.request.get('allow_edit_awards'):
auth_types_enum.append(AuthType.EVENT_AWARDS)
if self.request.get('allow_edit_match_video'):
auth_types_enum.append(AuthType.MATCH_VIDEO)
if self.request.get('allow_edit_info'):
auth_types_enum.append(AuthType.EVENT_INFO)
if self.request.get('owner', None):
owner = Account.query(Account.email == self.request.get('owner')).fetch()
owner_key = owner[0].key if owner else None
else:
owner_key = None
if self.request.get('expiration', None):
expiration = datetime.strptime(self.request.get('expiration'), '%Y-%m-%d')
else:
expiration = None
if self.request.get('event_list_str'):
split_events = self.request.get('event_list_str', '').split(',')
event_list = [ndb.Key(Event, event_key.strip()) for event_key in split_events]
else:
event_list = []
if not auth:
auth = ApiAuthAccess(
id=auth_id,
description=self.request.get('description'),
owner=owner_key,
expiration=expiration,
allow_admin=True if self.request.get('allow_admin') else False,
secret=''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for _ in range(64)),
event_list=event_list,
auth_types_enum=auth_types_enum,
)
else:
auth.description = self.request.get('description')
auth.event_list = event_list
auth.auth_types_enum = auth_types_enum
auth.owner = owner_key
auth.expiration = expiration
auth.allow_admin = True if self.request.get('allow_admin') else False
auth.put()
self.redirect("/admin/api_auth/manage")