本文整理汇总了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
示例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
示例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)
示例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)
示例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)
示例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()