本文整理汇总了Python中r2.models.account.Account._byID方法的典型用法代码示例。如果您正苦于以下问题:Python Account._byID方法的具体用法?Python Account._byID怎么用?Python Account._byID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.models.account.Account
的用法示例。
在下文中一共展示了Account._byID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_participant_account
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID [as 别名]
def get_participant_account(self):
if self.is_internal:
return None
try:
convo_participant = ModmailConversationParticipant.get_participant(
self.id)
participant = Account._byID(convo_participant.account_id)
except NotFound:
if not self.is_auto:
raise
return None
if participant._deleted:
raise NotFound
return participant
示例2: top_promoters
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID [as 别名]
def top_promoters(cls, start_date, end_date = None):
end_date = end_date or datetime.datetime.now(g.tz)
q = cls.for_date_range(start_date, end_date)
d = start_date
res = []
accounts = Account._byID([i.account_id for i in q],
return_dict = True, data = True)
res = {}
for i in q:
if i.bid is not None and i.actual_start is not None:
r = res.setdefault(i.account_id, [0, 0, set()])
r[0] += i.bid
r[1] += i.refund
r[2].add(i.thing_name)
res = [ ([accounts[k]] + v) for (k, v) in res.iteritems() ]
res.sort(key = lambda x: x[1] - x[2], reverse = True)
return res
示例3: update_sr_mods_modmail_icon
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID [as 别名]
def update_sr_mods_modmail_icon(sr):
"""Helper method to set the modmail icon for mods with mail permissions
for the passed sr.
Method will lookup all moderators for the passed sr and query whether they
have unread conversations that exist. If the user has unreads the modmail
icon will be lit up, if they do not it will be disabled.
Args:
sr -- Subreddit object to fetch mods with mail perms from
"""
mods_with_perms = sr.moderators_with_perms()
modmail_user_ids = [mod_id for mod_id, perms in mods_with_perms.iteritems()
if 'mail' in perms or 'all' in perms]
mod_accounts = Account._byID(modmail_user_ids, ignore_missing=True,
return_dict=False)
mail_exists_by_user = (ModmailConversationUnreadState
.users_unreads_exist(mod_accounts))
for mod in mod_accounts:
set_modmail_icon(mod, bool(mail_exists_by_user.get(mod._id)))
示例4: to_serializable
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID [as 别名]
def to_serializable(self, author=None):
if not author:
from r2.models import Account
author = Account._byID(self.account_id)
name = author.name
author_id = author._id
if author._deleted:
name = '[deleted]'
author_id = None
return {
'id': to36(self.id),
'author': {
'id': author_id,
'name': name,
'isAdmin': author.employee,
'isMod': True,
'isHidden': False,
'isDeleted': author._deleted
},
'actionTypeId': self.action_type_id,
'date': self.date.isoformat(),
}
示例5: _developers
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID [as 别名]
def _developers(self):
"""Returns a list of users who are developers of this client."""
devs = Account._byID(list(self._developer_ids))
return [dev for dev in devs.itervalues()
if not (dev._deleted or dev._spam)]
示例6: _developers
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _byID [as 别名]
def _developers(self):
"""Returns a list of users who are developers of this client."""
devs = Account._byID(list(self._developer_ids), return_dict=False)
return [dev for dev in devs if not dev._deleted]