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


Python User.get_by_id方法代码示例

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


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

示例1: get_user_from_request

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_id [as 别名]
def get_user_from_request(user_id=None, user_email=None, team_key=None):
    user = None
    if user_id:
        user = User.get_by_id(user_id)
    elif user_email:
        user = User.find_user_by_email(user_email, team_key)
    return user
开发者ID:usersource,项目名称:anno,代码行数:9,代码来源:utils.py

示例2: to_message

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_id [as 别名]
    def to_message(self, team_key=None, auth_user=None):
        """
        Convert FollowUp data model to follow up message.
        """
        message = FollowupMessage()
        message.id = self.key.id()
        message.anno_id = self.anno_key.id()
        message.comment = self.comment
        message.created = self.created

        message.tagged_users_detail = []
        for user in self.tagged_users:
            user_info = User.get_by_id(int(user))
            is_auth_user = (user_info.user_email == auth_user.user_email) if auth_user else False
            message.tagged_users_detail.append(UserMessage(id=user_info.key.id(),
                                                           display_name=user_info.display_name,
                                                           user_email=user_info.user_email,
                                                           image_url=user_info.image_url,
                                                           is_auth_user=is_auth_user))

        if self.creator is not None:
            user_info = self.creator.get()
            message.creator = UserMessage(display_name=user_info.display_name, image_url=user_info.image_url)

        return message
开发者ID:usersource,项目名称:anno,代码行数:27,代码来源:follow_up.py

示例3: tag_users

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_id [as 别名]
    def tag_users(cls, anno, prev_tagged_users_list, new_tagged_users_list):
        for prev_tagged_user in prev_tagged_users_list:
            user = User.get_by_id(int(prev_tagged_user))
            if user:
                userannostate = cls.get(user, anno)
                if userannostate:
                    userannostate.tagged = False
                    userannostate.put()

        for new_tagged_user in new_tagged_users_list:
            user = User.get_by_id(int(new_tagged_user))
            if user:
                userannostate = cls.get(user, anno)
                if userannostate:
                    userannostate.tagged = True
                    userannostate.put()
                else:
                    cls.insert(user, anno, AnnoActionType.TAGGEDUSER)
开发者ID:usersource,项目名称:anno,代码行数:20,代码来源:userannostate.py

示例4: followup_insert

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_id [as 别名]
    def followup_insert(self, request):
        """
        Exposes and API endpoint to insert a follow up for the current user.
        """
        user = auth_user(self.request_state.headers)

        anno = Anno.get_by_id(request.anno_id)
        if anno is None:
            raise endpoints.NotFoundException('No anno entity with the id "%s" exists.' % request.id)

        followup = FollowUp()
        followup.anno_key = anno.key
        followup.creator = user.key
        followup.comment = request.comment
        followup.tagged_users = request.tagged_users
        if request.created is not None:
            followup.created = request.created
        followup.put()

        anno.followup_count += 1
        anno.last_update_time = datetime.datetime.now()
        anno.last_activity = 'follwup'
        anno.last_update_type = 'create'
        anno.put()

        # update user anno state
        UserAnnoState.insert(user=user, anno=anno, type=AnnoActionType.COMMENTED)

        for tagged_user_id in followup.tagged_users:
            tagged_user = User.get_by_id(int(tagged_user_id))
            if tagged_user:
                UserAnnoState.insert(user=tagged_user, anno=anno, type=AnnoActionType.TAGGEDUSER)

        # update search document
        put_search_document(anno.generate_search_document(), SearchIndexName.ANNO)
        put_search_document(followup.generate_search_document(), SearchIndexName.FOLLOWUP)

        # find all hashtags
        tags = extract_tags_from_text(followup.comment.lower())
        for tag, count in tags.iteritems():
            # Write the cumulative amount per tag
            Tag.add_tag_total(tag, total=count)

        # send notifications
        ActivityPushNotifications.send_push_notification(first_user=user, anno=anno, action_type=AnnoActionType.COMMENTED,
                                                         comment=request.comment)

        return followup.to_message(request.team_key)
开发者ID:usersource,项目名称:anno,代码行数:50,代码来源:followup_api.py

示例5: anno_teamnotes_insert

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_id [as 别名]
    def anno_teamnotes_insert(self, request):
        anno = Anno.get_by_id(request.id)
        user = auth_user(self.request_state.headers)

        if anno:
            anno.team_notes = request.team_notes
            UserAnnoState.tag_users(anno, anno.tagged_users, request.tagged_users)
            anno.tagged_users = request.tagged_users
            anno.put()

        mentions = []
        for tagged_user in request.tagged_users:
            user_info = User.get_by_id(int(tagged_user))
            is_auth_user = user_info.user_email == user.user_email
            mentions.append(AnnoMentionsResponseMessage(id=user_info.key.id(),
                                                        display_name=user_info.display_name,
                                                        user_email=user_info.user_email,
                                                        image_url=user_info.image_url,
                                                        is_auth_user=is_auth_user))

        return AnnoTeamNotesMetadataMessage(tags=parseTeamNotesForHashtags(request.team_notes),
                                            mentions=mentions)
开发者ID:usersource,项目名称:anno,代码行数:24,代码来源:anno_api.py

示例6: get_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_id [as 别名]
def get_user(id_):
    return User.get_by_id(id_).get_info()
开发者ID:uthunderbird,项目名称:neo4j-experiment,代码行数:4,代码来源:user.py


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