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


Python Mobile.get方法代码示例

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


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

示例1: _create_unread_messages

# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import get [as 别名]
def _create_unread_messages(stats, language, server_settings, user_profile):
    sender_users = list({s[0] for s in stats[1] if s[0] != MC_DASHBOARD})
    sender_profile_infos = dict(zip(sender_users, get_profile_infos(sender_users, allow_none_in_results=True)))

    timezone_diff = 0
    if user_profile.mobiles:
        for mobile_detail in user_profile.mobiles:
            mobile = Mobile.get(Mobile.create_key(mobile_detail.account))
            timezone_diff = mobile.timezoneDeltaGMT or 0
            break

    avatars = dict()  # { avatar_id : (avatar_data) }
    def get_avatar_url(avatar_id):
        avatar = avatars.get(avatar_id)
        if not avatar:
            if avatar_id in ('nuntiuz', 'unknown'):
                if avatar == 'nuntiuz':
                    avatar = UNKNOWN_AVATAR
                else:
                    avatar = NUNTIUZ_AVATAR
            else:
                avatar = get_avatar_cached(avatar_id, size=40)
            avatars[avatar_id] = avatar
        return 'cid:%s' % avatar_id

    unread_messages = list()  # sorted by message.creationTimestamp
    for sender_user, message, broadcast_type, creation_time in sorted(stats[1], key=lambda x: x[3]):
        sender_profile_info = sender_profile_infos.get(sender_user)
        if sender_profile_info:
            name = sender_profile_info.name
            avatar_url = get_avatar_url(sender_profile_info.avatarId)
        elif sender_user == MC_DASHBOARD:
            name = get_profile_info_name(sender_user, user_profile.app_id)
            avatar_url = get_avatar_url('nuntiuz')
        else:
            name = sender_user.email().split(':', 1)[0].split('/', 1)[0]
            avatar_url = get_avatar_url('unknown')

        creation_date_time = datetime.datetime.utcfromtimestamp(creation_time + timezone_diff)
        creation_time_str = '%s, %s' % (format_date(creation_date_time, locale=language, format='short'),
                                        format_time(creation_date_time, locale=language, format='short'))

        if broadcast_type:
            sender_user = add_slash_default(sender_user)

        if len(name) > 43:
            name = name[:40] + u'...'

        unread_messages.append(UnreadMessage(name, avatar_url, message, broadcast_type, creation_time_str,
                                             localize(language, 'email_reminder_unsubscribe_caption',
                                                      notification_type=xml_escape(broadcast_type) if broadcast_type else None,
                                                      service=xml_escape(name)),
                                             generate_unsubscribe_broadcast_link(user_profile.user, sender_user, name,
                                                                                 broadcast_type)))
    return unread_messages, avatars
开发者ID:gitter-badger,项目名称:rogerthat-backend,代码行数:57,代码来源:send_unread_messages.py

示例2: get_mobile_by_key

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


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