• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python account.Account类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中r2.models.account.Account的典型用法代码示例。如果您正苦于以下问题:Python Account类的具体用法?Python Account怎么用?Python Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setUp

 def setUp(self):
     a = Account()
     a._commit()
     sr = Subreddit(name = 'subreddit_name_%s' % (self.seconds_since_epoc(),),
                    title = 'subreddit_title_%s' % (self.seconds_since_epoc(),),)
     sr._commit()
     self.rel = SRMember(sr, a, 'test')
开发者ID:caseypatrickdriscoll,项目名称:reddit,代码行数:7,代码来源:subreddit_test.py


示例2: get_editor_accounts

 def get_editor_accounts(self):
     editors = self.get_editors()
     accounts = [Account._byID36(editor, data=True)
                 for editor in self.get_editors()]
     accounts = [account for account in accounts
                 if not account._deleted]
     return accounts
开发者ID:99plus2,项目名称:reddit,代码行数:7,代码来源:wiki.py


示例3: get_author_name

def get_author_name(author_name):
    if not author_name:
        return "[unknown]"
    try:
        return Account._by_name(author_name).name
    except NotFound:
        return "[deleted]"
开发者ID:nandhinijie,项目名称:reddit,代码行数:7,代码来源:wiki.py


示例4: check_valid

    def check_valid(self):
        """Returns boolean indicating whether or not this access token is still valid."""

        # Has the token been revoked?
        if getattr(self, 'revoked', False):
            return False

        # Is the OAuth2Client still valid?
        try:
            client = OAuth2Client._byID(self.client_id)
            if getattr(client, 'deleted', False):
                raise NotFound
        except NotFound:
            return False

        # Is the user account still valid?
        if self.user_id:
            try:
                account = Account._byID36(self.user_id)
                if account._deleted:
                    raise NotFound
            except NotFound:
                return False

        return True
开发者ID:njs0630,项目名称:reddit,代码行数:25,代码来源:token.py


示例5: revoke

 def revoke(self):
     super(OAuth2RefreshToken, self).revoke()
     account = Account._byID36(self.user_id)
     access_tokens = OAuth2AccessToken._by_user(account)
     for token in access_tokens:
         if token.refresh_token == self._id:
             token.revoke()
开发者ID:njs0630,项目名称:reddit,代码行数:7,代码来源:token.py


示例6: _copy_multi

    def _copy_multi(self, from_multi, to_path_info):
        self._check_new_multi_path(to_path_info)

        to_owner = Account._by_name(to_path_info["username"])

        try:
            LabeledMulti._byID(to_path_info["path"])
        except tdb_cassandra.NotFound:
            to_multi = LabeledMulti.copy(to_path_info["path"], from_multi, owner=to_owner)
        else:
            raise RedditError("MULTI_EXISTS", code=409, fields="multipath")

        return to_multi
开发者ID:JBTech,项目名称:reddit,代码行数:13,代码来源:multi.py


示例7: get_participant_account

    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
开发者ID:zeantsoi,项目名称:reddit,代码行数:17,代码来源:modmail.py


示例8: top_promoters

    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
开发者ID:Jeerok,项目名称:reddit,代码行数:19,代码来源:bidding.py


示例9: check_valid

    def check_valid(self):
        if getattr(self, 'revoked', False):
            return False

        try:
            client = OAuth2Client._byID(self.client_id)
            if getattr(client, 'deleted', False):
                raise NotFound
        except AttributeError:
            g.log.error("bad token %s: %s", self, self._t)
            raise
        except NotFound:
            return False

        if self.user_id:
            try:
                account = Account._byID36(self.user_id)
                if account._deleted:
                    raise NotFound
            except NotFound:
                return False

        return True
开发者ID:zeantsoi,项目名称:reddit,代码行数:23,代码来源:token.py


示例10: to_serializable

    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(),
        }
开发者ID:zeantsoi,项目名称:reddit,代码行数:24,代码来源:modmail.py


示例11: update_sr_mods_modmail_icon

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)))
开发者ID:zeantsoi,项目名称:reddit,代码行数:24,代码来源:modmail.py


示例12: _developers

    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)]
开发者ID:njs0630,项目名称:reddit,代码行数:6,代码来源:token.py


示例13: setUp

 def setUp(self):
     a = Account()
     a._id = 1
     sr = Subreddit()
     sr._id = 2
     self.rel = SRMember(sr, a, 'test')
开发者ID:brainfish,项目名称:reddit,代码行数:6,代码来源:subreddit_test.py


示例14: valid_for_credentials

 def valid_for_credentials(self, email, password):
     user = Account._by_fullname(self.user_id)
     return (self.email_address.lower() == email.lower() and
             valid_password(user, password, self.password))
开发者ID:zeantsoi,项目名称:reddit,代码行数:4,代码来源:token.py


示例15: is_first_party

 def is_first_party(self):
     return self.has_developer(Account.system_user())
开发者ID:zeantsoi,项目名称:reddit,代码行数:2,代码来源:token.py


示例16: _developers

    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]
开发者ID:zeantsoi,项目名称:reddit,代码行数:5,代码来源:token.py


示例17: register

# Initialise a newly-created db with required tables, users,
# categories and tags.
from r2.lib.db.thing import NotFound
from r2.models.account import Account, AccountExists, register
from r2.models.link import Tag, TagExists
from r2.models.subreddit import Subreddit

try:
    register("admin", "swordfish", "", False)
except AccountExists:
    pass

admin = Account._by_name("admin")
admin.email_validated = True
admin._commit()

try:
    Subreddit._by_name("lesswrong")
except NotFound:
    Subreddit._create_and_subscribe(
        "lesswrong", admin, {"title": "Less Wrong", "type": "restricted", "default_listing": "blessed"}
    )

try:
    Subreddit._by_name("discussion")
except NotFound:
    s = Subreddit._create_and_subscribe(
        "discussion", admin, {"title": "Less Wrong Discussion", "type": "public", "default_listing": "new"}
    )
    s.header = "/static/logo-discussion.png"
    s.stylesheet = "/static/discussion.css"
开发者ID:brendanlong,项目名称:lesswrong,代码行数:31,代码来源:bootstrap.py


示例18: register

# Initialise a newly-created db with required tables, users,
# categories and tags.
from r2.lib.db.thing import NotFound
from r2.models.account import Account, AccountExists, register
from r2.models.link import Tag, TagExists
from r2.models.subreddit import Subreddit

try:
    register('admin', 'swordfish', '')
except AccountExists:
    pass

admin = Account._by_name('admin')
admin.email_validated = True
admin._commit()

try:
    Subreddit._by_name('admin')
except NotFound:
    Subreddit._create_and_subscribe('admin', admin,
                                    { 'title': 'Admin',
                                      'type': 'restricted',
                                      'default_listing': 'new' })

try:
    Subreddit._by_name('main')
except NotFound:
    Subreddit._create_and_subscribe('main', admin,
                                    { 'title': 'EA Forum',
                                      'type': 'restricted',
                                      'default_listing': 'new' })
开发者ID:RyanCarey,项目名称:eaforum,代码行数:31,代码来源:bootstrap.py


示例19: get_authors

 def get_authors(cls, revisions):
     authors = [r._get('author') for r in revisions]
     authors = filter(None, authors)
     return Account._byID36(authors, data=True)
开发者ID:99plus2,项目名称:reddit,代码行数:4,代码来源:wiki.py


示例20: get_author

 def get_author(self):
     author = self._get('author')
     return Account._byID36(author, data=True) if author else None
开发者ID:99plus2,项目名称:reddit,代码行数:3,代码来源:wiki.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python account.FakeAccount类代码示例发布时间:2022-05-26
下一篇:
Python models.Vote类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap