当前位置: 首页>>代码示例>>Python>>正文


Python MobileClient.get_by_id方法代码示例

本文整理汇总了Python中models.mobile_client.MobileClient.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python MobileClient.get_by_id方法的具体用法?Python MobileClient.get_by_id怎么用?Python MobileClient.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.mobile_client.MobileClient的用法示例。


在下文中一共展示了MobileClient.get_by_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models.mobile_client import MobileClient [as 别名]
# 或者: from models.mobile_client.MobileClient import get_by_id [as 别名]
    def post(self):
        self._require_registration()

        # Check to make sure that they aren't trying to edit another user
        current_user_account_id = self.user_bundle.account.key.id()
        target_account_id = self.request.get('account_id')
        if target_account_id == current_user_account_id:
            client_id = self.request.get('client_id')
            client = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id))
            if client is not None:
                # This makes sure that the client actually exists and that this user owns it
                NotificationHelper.send_ping(client)
                return self.redirect('/account?ping_sent=1')
        self.redirect('/')
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:16,代码来源:notification_controller.py

示例2: post

# 需要导入模块: from models.mobile_client import MobileClient [as 别名]
# 或者: from models.mobile_client.MobileClient import get_by_id [as 别名]
    def post(self):
        self._require_registration()

        # Check to make sure that they aren't trying to edit another user
        current_user_account_id = self.user_bundle.account.key.id()
        target_account_id = self.request.get('account_id')
        if target_account_id == current_user_account_id:
            client_id = self.request.get('client_id')
            client = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id))
            if client is not None:
                # This makes sure that the client actually exists and that this user owns it
                if client.client_type == ClientType.WEBHOOK:
                    keys = {client.client_type: [(client.messaging_id, client.secret)]}
                else:
                    keys = {client.client_type: [client.messaging_id]}
                notification = PingNotification()
                notification.send(keys)
            self.redirect('/account')
        else:
            self.redirect('/')
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:22,代码来源:notification_controller.py

示例3: post

# 需要导入模块: from models.mobile_client import MobileClient [as 别名]
# 或者: from models.mobile_client.MobileClient import get_by_id [as 别名]
    def post(self):
        self._require_registration()

        current_user_account_id = self.user_bundle.account.key.id()
        target_account_id = self.request.get('account_id')
        if target_account_id == current_user_account_id:
            client_id = self.request.get('client_id')
            webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id))
            if webhook.client_type == ClientType.WEBHOOK and current_user_account_id == webhook.user_id:
                verification_key = NotificationHelper.verify_webhook(webhook.messaging_id, webhook.secret)
                webhook.verification_code = verification_key
                webhook.verified = False
                webhook.put()
                self.redirect('/account')
                return
            else:
                logging.warning("Not webhook, or wrong owner")
        else:
            logging.warning("Users don't match. "+current_user_account_id+"/"+target_account_id)
        self.redirect('/')
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:22,代码来源:webhook_controller.py

示例4: post

# 需要导入模块: from models.mobile_client import MobileClient [as 别名]
# 或者: from models.mobile_client.MobileClient import get_by_id [as 别名]
    def post(self, client_id):
        self._require_registration()
        self._require_request_user_is_bundle_user()

        current_user_account_id = self.user_bundle.account.key.id()
        if not current_user_account_id:
            return self.redirect('/')

        verification = self.request.get('code')
        if not verification:
            return self.redirect('/webhooks/verify/{}?error=1'.format(webhook.key.id()))

        webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id))
        if not webhook or webhook.client_type != ClientType.WEBHOOK or current_user_account_id != webhook.user_id:
            return self.redirect('/')

        if verification == webhook.verification_code:
            webhook.verified = True
            webhook.put()
            return self.redirect('/account?webhook_verification_success=1')
        else:
            # Redirect back to the verification page
            return self.redirect('/webhooks/verify/{}?error=1'.format(webhook.key.id()))
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:25,代码来源:webhook_controller.py


注:本文中的models.mobile_client.MobileClient.get_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。