本文整理匯總了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")