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


Python UserProfile.avatarId方法代码示例

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


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

示例1: trans_create

# 需要导入模块: from rogerthat.models import UserProfile [as 别名]
# 或者: from rogerthat.models.UserProfile import avatarId [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 avatarId [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 avatarId [as 别名]

#.........这里部分代码省略.........
                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())
            user_profile.name = None
            user_profile.language = language
            user_profile.avatarId = avatar.key().id()
            user_profile.app_id = get_app_id_from_app_user(app_user)
            user_details = [UserDetailsTO.fromUserProfile(user_profile)]
            r = service_api_friends.register(None, None, svc_profile,
                                             service_identity=service_identity,
                                             user_details=user_details,
                                             origin=REGISTRATION_ORIGIN_QR,
                                             PERFORM_CALLBACK_SYNCHRONOUS=True)

            logging.debug("register_via_qr with id: %s", r)
            bizz_check(r == ACCEPT_ID or r == ACCEPT_AND_CONNECT_ID, u"Service denied your install")

            installation.service_identity_user = service_identity_user
            installation.service_callback_result = r
            installation.qr_url = su.full[4:]
            installation.put()

            # Create registration entry.
            self.response.headers['Content-Type'] = 'text/json'
            registration = Registration(parent=parent_key(app_user), key_name=registration_id)
            registration.timestamp = int(registration_time)
            registration.device_id = device_id
            registration.pin = -1
            registration.timesleft = -1
            registration.installation = installation
            registration.language = language
            registration.put()
            account, registration.mobile, age_and_gender_set = register_mobile(human_user, app_id=app_id,
                                                                               use_xmpp_kick_channel=use_xmpp_kick_channel,
                                                                               GCM_registration_id=GCM_registration_id,
                                                                               language=registration.language)
            installation_log = InstallationLog(parent=installation, timestamp=now(), profile=get_user_profile(app_user), \
                                               description="Profile created & registration request validated.", \
                                               registration=registration, mobile=registration.mobile)
            db.put([registration, installation_log])
            self.response.out.write(json.dumps(dict(account=account.to_dict(), email=human_user.email(), age_and_gender_set=age_and_gender_set)))
        except BusinessException, be:
            logging.debug("BusinessException during via QR handler %s", be)
            self.response.set_status(500)
            return
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:104,代码来源:register_mobile.py


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