當前位置: 首頁>>代碼示例>>Python>>正文


Python UserProfile.app_id方法代碼示例

本文整理匯總了Python中rogerthat.models.UserProfile.app_id方法的典型用法代碼示例。如果您正苦於以下問題:Python UserProfile.app_id方法的具體用法?Python UserProfile.app_id怎麽用?Python UserProfile.app_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rogerthat.models.UserProfile的用法示例。


在下文中一共展示了UserProfile.app_id方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: trans_create

# 需要導入模塊: from rogerthat.models import UserProfile [as 別名]
# 或者: from rogerthat.models.UserProfile import app_id [as 別名]
    def trans_create():
        rogerthat_profile = get_service_or_user_profile(users.User(email))
        if rogerthat_profile and isinstance(rogerthat_profile, ServiceProfile):
            from rogerthat.bizz.service import AppFailedToCreateUserProfileWithExistingServiceException
            raise AppFailedToCreateUserProfileWithExistingServiceException(email)

        user_profile = get_user_profile(app_user, cached=False)
        is_new_profile = False
        if not user_profile:
            deactivated_user_profile = get_deactivated_user_profile(app_user)
            if deactivated_user_profile:
                deferred.defer(reactivate_user_profile, deactivated_user_profile, app_user, _transactional=True)
                ActivationLog(timestamp=now(), email=app_user.email(), mobile=None, description="Reactivate user account by registering a paper loyalty card").put()
            else:
                is_new_profile = True
                avatar, image = _create_new_avatar(app_user, add_trial_overlay=False)

                user_profile = UserProfile(parent=parent_key(app_user), key_name=app_user.email())
                user_profile.name = name
                user_profile.language = language
                user_profile.avatarId = avatar.key().id()
                user_profile.app_id = app_id
                _calculateAndSetAvatarHash(user_profile, image)

        pp = ProfilePointer(key=db.Key.from_path(ProfilePointer.kind(), user_code))
        pp.user = app_user
        pp.short_url_id = short_url_id

        if is_new_profile:
            put_and_invalidate_cache(user_profile, pp, ProfilePointer.create(app_user))
        else:
            pp.put()
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:34,代碼來源:profile.py

示例2: trans_create

# 需要導入模塊: from rogerthat.models import UserProfile [as 別名]
# 或者: from rogerthat.models.UserProfile import app_id [as 別名]
    def trans_create(avatar_image):
        azzert(not get_user_profile(app_user, cached=False))

        avatar, image = _create_new_avatar(app_user, False, avatar_image)

        user_profile = UserProfile(parent=parent_key(app_user), key_name=app_user.email())
        user_profile.name = name
        user_profile.language = language
        user_profile.avatarId = avatar.key().id()
        user_profile.app_id = get_app_id_from_app_user(app_user)
        user_profile.owncloud_password = owncloud_password
        if tos_version:
            user_profile.tos_version = tos_version
        if consent_push_notifications_shown:
            user_profile.consent_push_notifications_shown = True
        _calculateAndSetAvatarHash(user_profile, image)

        put_and_invalidate_cache(user_profile, ProfilePointer.create(app_user), ProfileHashIndex.create(app_user))

        return user_profile
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:22,代碼來源:profile.py

示例3: post

# 需要導入模塊: from rogerthat.models import UserProfile [as 別名]
# 或者: from rogerthat.models.UserProfile import app_id [as 別名]
    def post(self):
        from rogerthat.pages.shortner import get_short_url_by_code
        from rogerthat.service.api import friends as service_api_friends

        version = self.request.get("version", None)
        install_id = self.request.get("install_id", None)
        registration_time = self.request.get("registration_time", None)
        device_id = self.request.get("device_id", None)
        registration_id = self.request.get("registration_id", None)
        qr_url = self.request.get("qr_url", None)
        signature = self.request.get("signature", None)
        language = self.request.get("language", None)
        country = self.request.get("country", None)
        app_id = self.request.get("app_id", App.APP_ID_ROGERTHAT)
        use_xmpp_kick_channel = self.request.get('use_xmpp_kick', 'true') == 'true'
        GCM_registration_id = self.request.get('GCM_registration_id', '')

        if '-' in language:
            language = get_iso_lang(language.lower())
        elif language and country:
            language = '%s_%s' % (language, country)

        server_settings = get_server_settings()

        calculated_signature = sha256_hex(version + " " + install_id + " " + registration_time + " " + device_id + " " + \
                                       registration_id + " " + qr_url + base64.b64decode(server_settings.registrationMainSignature.encode("utf8")))

        try:
            if signature.upper() != calculated_signature.upper():
                logging.error("Invalid request signature.")
                self.response.set_status(500)
                return

            app = _verify_app_id(app_id)
            azzert(app is not None, "app_id is not found")
            bizz_check(install_id and qr_url, u"Could not validate QR code")

            installation = Installation.get_by_key_name(install_id)
            if not installation:
                platform = self.request.get("platform", None)
                if platform == "android":
                    mobile_type = Mobile.TYPE_ANDROID_HTTP
                elif platform == "iphone":
                    if use_xmpp_kick_channel:
                        mobile_type = Mobile.TYPE_IPHONE_HTTP_XMPP_KICK
                    else:
                        mobile_type = Mobile.TYPE_IPHONE_HTTP_APNS_KICK
                elif platform == "windows_phone":
                    mobile_type = Mobile.TYPE_WINDOWS_PHONE
                else:
                    logging.error("Unknown platform: %s" % platform)
                    self.response.set_status(500)
                    return

                now_ = now()
                installation = Installation(key_name=install_id, version=version, platform=mobile_type, timestamp=now_, app_id=app_id)
                installation_log = InstallationLog(parent=installation, timestamp=now_,
                                              description="Installed with language %s" % language)
                installation_log_app_id = InstallationLog(parent=installation, timestamp=now_,
                                                  description="Installed with app_id: %s" % app_id)
                put_and_invalidate_cache(installation, installation_log, installation_log_app_id)

            InstallationLog(parent=installation, timestamp=now(),
                            description="Creating qr based profile & validating registration request. Language: %s, QR url: %s" % (language, qr_url)).put()

            m = re.match('(.*)/(M|S)/(.*)', qr_url)
            bizz_check(m, u"Could not validate QR code")
            entry_point = m.group(2)
            code = m.group(3)

            bizz_check(entry_point == "S", u"Could not validate QR code")

            su = get_short_url_by_code(code)
            bizz_check(su, u"Could not validate QR code")

            logging.debug("register_via_qr qr_url: %s", qr_url)
            logging.debug("register_via_qr su.full: %s", su.full)

            match = re.match("^/q/s/(.+)/(\\d+)$", su.full)
            bizz_check(match, u"Could not validate QR code")

            user_code = match.group(1)
            service_profile = get_service_profile_via_user_code(user_code)
            bizz_check(service_profile, u"Could not validate QR code")

            service_user = service_profile.user

            sid = int(match.group(2))
            service_interaction_def = get_service_interaction_def(service_user, int(sid))
            service_identity_user = create_service_identity_user(service_user, service_interaction_def.service_identity)
            service_identity = get_identity_from_service_identity_user(service_identity_user)
            svc_profile = get_service_profile(service_user)

            logging.debug("register_via_qr service_identity_user: %s", service_identity_user)

            human_user = users.User(u"user%[email protected]" % uuid.uuid4().get_hex())
            app_user = create_app_user(human_user, app_id)
            from rogerthat.bizz.profile import _create_new_avatar
            avatar, _ = _create_new_avatar(app_user, add_trial_overlay=False)
            user_profile = UserProfile(parent=parent_key(app_user), key_name=app_user.email())
#.........這裏部分代碼省略.........
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:103,代碼來源:register_mobile.py


注:本文中的rogerthat.models.UserProfile.app_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。