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


Python Mobile.pushId方法代码示例

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


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

示例1: register_mobile

# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import pushId [as 别名]
def register_mobile(human_user, name=None, app_id=App.APP_ID_ROGERTHAT, use_xmpp_kick_channel=True,
                    GCM_registration_id=None, language=None, ysaaa=False):
    # First unregister currently registered mobiles
    app_user = create_app_user(human_user, app_id)
    mobiles = get_user_active_mobiles(app_user)
    for m in mobiles:
        unregister_mobile(app_user, m)

    # Create account
    account = generate_account()

    # Save mobile in datastore
    mobile = Mobile(key_name=account.account)
    mobile.id = unicode(uuid.uuid1())
    mobile.description = "%s mobile" % app_user.email()

    mobile.user = app_user
    mobile.account = account.account
    mobile.accountPassword = account.password
    need_jabber_account = not APPSCALE and use_xmpp_kick_channel
    if need_jabber_account:
        mobile.status = Mobile.STATUS_NEW  # Account created status is set as soon as the ejabberd account is ready
    else:
        mobile.status = Mobile.STATUS_NEW | Mobile.STATUS_ACCOUNT_CREATED
    if GCM_registration_id:
        mobile.pushId = GCM_registration_id
    mobile.put()

    # AppScale deployments authenticate jabber users against rogerthat app directly
    if need_jabber_account:
        try_or_defer(create_jabber_account, account, mobile.key())

    age_and_gender_set = False

    # Create profile for user if needed
    deactivated_user_profile = get_deactivated_user_profile(app_user)
    if deactivated_user_profile:
        if deactivated_user_profile.birthdate is not None and deactivated_user_profile.gender is not None:
            age_and_gender_set = True
        reactivate_user_profile(deactivated_user_profile, app_user)
        ActivationLog(timestamp=now(), email=app_user.email(), mobile=mobile,
                      description="Reactivate user account by registering a mobile").put()
    else:
        user_profile = get_user_profile(app_user)
        if not user_profile:
            create_user_profile(app_user, name or human_user.email(), language, ysaaa)
        else:
            if user_profile.birthdate is not None and user_profile.gender is not None:
                age_and_gender_set = True
            if user_profile.isCreatedForService:
                user_profile.isCreatedForService = False
                user_profile.put()

    return account, mobile, age_and_gender_set
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:56,代码来源:registration.py

示例2: register_mobile

# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import pushId [as 别名]
def register_mobile(human_user, name=None, app_id=App.APP_ID_ROGERTHAT, use_xmpp_kick_channel=True,
                    gcm_registration_id=None, language=None, ysaaa=False, firebase_registration_id=None,
                    hardware_model=None, sim_carrier_name=None, tos_version=None,
                    consent_push_notifications_shown=False, anonymous_account=None):
    if anonymous_account:
        anonymous_mobile = get_mobile_by_account(anonymous_account)
        azzert(anonymous_mobile)

    # First unregister currently registered mobiles
    app_user = create_app_user(human_user, app_id)
    mobiles = get_user_active_mobiles(app_user)

    reason = None
    device_name = get_device_name(hardware_model, sim_carrier_name)
    if device_name:
        reason = localize(language, u"Your device was unregistered because the same account was used to register the following device '%(device_name)s'",
                          device_name=device_name)

    for m in mobiles:
        unregister_mobile(app_user, m, reason)

    # Create account
    account = generate_account()

    # Save mobile in datastore
    mobile = Mobile(key_name=account.account)
    mobile.id = unicode(uuid.uuid1())
    mobile.description = "%s mobile" % app_user.email()

    mobile.user = app_user
    mobile.account = account.account
    mobile.accountPassword = account.password
    need_jabber_account = not APPSCALE and use_xmpp_kick_channel
    if need_jabber_account:
        mobile.status = Mobile.STATUS_NEW  # Account created status is set as soon as the ejabberd account is ready
    else:
        mobile.status = Mobile.STATUS_NEW | Mobile.STATUS_ACCOUNT_CREATED
    if gcm_registration_id:
        mobile.pushId = gcm_registration_id
    if firebase_registration_id:
        mobile.pushId = firebase_registration_id
    mobile.put()

    # AppScale deployments authenticate jabber users against rogerthat app directly
    if need_jabber_account:
        try_or_defer(create_jabber_account, account, mobile.key())

    age_and_gender_set = False
    app = get_app_by_id(app_id)
    owncloud_password = unicode(uuid.uuid4()) if app.owncloud_base_uri else None

    # Create profile for user if needed
    deactivated_user_profile = get_deactivated_user_profile(app_user)
    if deactivated_user_profile:
        if deactivated_user_profile.birthdate is not None and deactivated_user_profile.gender is not None:
            age_and_gender_set = True
        if owncloud_password and not deactivated_user_profile.owncloud_password:
            create_owncloud_account(
                app_user, app.owncloud_base_uri, app.owncloud_admin_username, app.owncloud_admin_password, owncloud_password)

        reactivate_user_profile(
            deactivated_user_profile, app_user, owncloud_password, tos_version, consent_push_notifications_shown)
        ActivationLog(timestamp=now(), email=app_user.email(), mobile=mobile,
                      description="Reactivate user account by registering a mobile").put()

    else:
        user_profile = get_user_profile(app_user)
        if not user_profile:
            create_user_profile(app_user, name or human_user.email(), language, ysaaa, owncloud_password, tos_version=tos_version,
                                consent_push_notifications_shown=consent_push_notifications_shown)
            if owncloud_password:
                create_owncloud_account(
                    app_user, app.owncloud_base_uri, app.owncloud_admin_username, app.owncloud_admin_password, owncloud_password)
        else:
            should_put = False
            if user_profile.birthdate is not None and user_profile.gender is not None:
                age_and_gender_set = True
            if user_profile.isCreatedForService:
                user_profile.isCreatedForService = False
                should_put = True
            if owncloud_password and not user_profile.owncloud_password:
                user_profile.owncloud_password = owncloud_password
                should_put = True
                create_owncloud_account(
                    app_user, app.owncloud_base_uri, app.owncloud_admin_username, app.owncloud_admin_password, owncloud_password)

            if tos_version:
                user_profile.tos_version = tos_version
                should_put = True

            if should_put:
                user_profile.put()

    return account, mobile, age_and_gender_set
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:96,代码来源:registration.py


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