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


Python Mobile.get_by_key_name方法代码示例

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


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

示例1: _send_notification_about_failed_location_fix

# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import get_by_key_name [as 别名]
def _send_notification_about_failed_location_fix(user, friend, friend_mobile_key_name, target, error_status):
    '''
    @param user: The user who sent the location request.
    @param friend: The user who failed to execute the location request.
    @param friend_mobile_key_name: The key name of the friend's Mobile model.
    @param target: The reason of the location request. One of GetLocationRequestTO.TARGET_*.
    @param error_status: The reason of the failed location request. One of GetLocationErrorTO.STATUS_*.
    '''
    friend_profile, user_profile = get_profile_infos([friend, user], expected_types=[UserProfile, UserProfile])
    app_name = get_app_name_by_id(user_profile.app_id)
    friend_msg = None
    user_reason_msg = None
    if error_status in (GetLocationErrorTO.STATUS_AUTHORIZATION_DENIED,
                        GetLocationErrorTO.STATUS_AUTHORIZATION_ONLY_WHEN_IN_USE):
        if error_status == GetLocationErrorTO.STATUS_AUTHORIZATION_DENIED:
            friend_msg = localize(friend_profile.language, "_location_services_denied",
                                  name=user_profile.name, app_name=app_name)
            user_reason_msg = localize(user_profile.language, "_friend_denied_location_services",
                                       name=friend_profile.name, app_name=app_name)
        elif error_status == GetLocationErrorTO.STATUS_AUTHORIZATION_ONLY_WHEN_IN_USE:
            friend_msg = localize(friend_profile.language, "_location_services_denied",
                                  name=user_profile.name, app_name=app_name)
            user_reason_msg = localize(user_profile.language, "_friend_denied_location_services",
                                       name=friend_profile.name, app_name=app_name)

        if friend_msg:
            friend_mobile = Mobile.get_by_key_name(friend_mobile_key_name)
            if friend_mobile.is_ios and friend_mobile.osVersion:
                if friend_mobile.osVersion.startswith('7'):
                    friend_msg += "\n\n" + localize(friend_profile.language, "_enable_location_services_ios7",
                                                    app_name=app_name)
                elif friend_mobile.osVersion.startswith('8'):
                    friend_msg += "\n\n" + localize(friend_profile.language, "_enable_location_services_ios8",
                                                    app_name=app_name)

    if target == GetLocationRequestTO.TARGET_MOBILE:
        user_msg = localize(user_profile.language,
                            "We could not determine the location of %(name)s.",
                            name=friend_profile.name)
    elif target == GetLocationRequestTO.TARGET_MOBILE_FIRST_REQUEST_AFTER_GRANT:
        user_msg = localize(user_profile.language,
                            "%(name)s accepted your location sharing request. Unfortunately we could not determine his/her location at this moment.",
                            name=friend_profile.name)
    else:
        logging.error("Don't know what to do in _send_notification_about_failed_location_fix.\n\nLocals:\n%s" % locals())
        return

    if user_reason_msg:
        user_msg = u"%s (%s)" % (user_msg, user_reason_msg)

    if user_msg and not friend_msg:
        user_msg = u"%s\n\n%s" % (user_msg, localize(user_profile.language, "Please try again later."))

    xg_on = db.create_transaction_options(xg=True)
    db.run_in_transaction_options(xg_on, dashboardNotification, user, user_msg)
    if friend_msg:
        db.run_in_transaction_options(xg_on, dashboardNotification, friend, friend_msg)
开发者ID:rogerthat-platform,项目名称:rogerthat-backend,代码行数:59,代码来源:location.py

示例2: get_mobile_by_account

# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import get_by_key_name [as 别名]
def get_mobile_by_account(account):
    return Mobile.get_by_key_name(account)
开发者ID:our-city-app,项目名称:mobicage-backend,代码行数:4,代码来源:mobile.py


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