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


Python Report.get_reasons方法代码示例

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


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

示例1: __init__

# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import get_reasons [as 别名]
    def __init__(self, thing, delete = True, report = True):
        # is the current user the author?
        is_author = thing.is_author
        # do we show the report button?
        show_report = not is_author and report and thing.can_reply
        # do we show the delete button?
        show_delete = is_author and delete and not thing._deleted

        show_distinguish = (is_author and
                            (thing.can_ban or  # Moderator distinguish
                             c.user.employee or  # Admin distinguish
                             c.user_special_distinguish))

        show_givegold = thing.can_gild

        PrintableButtons.__init__(self, "commentbuttons", thing,
                                  can_save=thing.can_save,
                                  is_author = is_author, 
                                  profilepage = c.profilepage,
                                  permalink = thing.permalink,
                                  saved = thing.saved,
                                  ignore_reports = thing.ignore_reports,
                                  full_comment_path = thing.full_comment_path,
                                  full_comment_count = thing.full_comment_count,
                                  deleted = thing.deleted,
                                  parent_permalink = thing.parent_permalink, 
                                  can_reply = thing.can_reply,
                                  show_report = show_report,
                                  report_reasons = Report.get_reasons(thing),
                                  show_distinguish = show_distinguish,
                                  show_delete = show_delete,
                                  show_givegold=show_givegold,
        )
开发者ID:JingyanZ,项目名称:reddit,代码行数:35,代码来源:things.py

示例2: thing_attr

# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import get_reasons [as 别名]
    def thing_attr(self, thing, attr):
        """
        For the benefit of subclasses, to lookup attributes which may
        require more work than a simple getattr (for example, 'author'
        which has to be gotten from the author_id attribute on most
        things).
        """
        if attr == "author":
            if thing.author._deleted:
                return "[deleted]"
            return thing.author.name
        if attr == "author_flair_text":
            if thing.author._deleted:
                return None
            if thing.author.flair_enabled_in_sr(thing.subreddit._id):
                return getattr(thing.author, "flair_%s_text" % (thing.subreddit._id), None)
            else:
                return None
        if attr == "author_flair_css_class":
            if thing.author._deleted:
                return None
            if thing.author.flair_enabled_in_sr(thing.subreddit._id):
                return getattr(thing.author, "flair_%s_css_class" % (thing.subreddit._id), None)
            else:
                return None
        elif attr == "created":
            return time.mktime(thing._date.timetuple())
        elif attr == "created_utc":
            return time.mktime(thing._date.astimezone(pytz.UTC).timetuple()) - time.timezone
        elif attr == "child":
            return CachedVariable("childlisting")
        elif attr == "upvotes":
            return thing.score
        elif attr == "downvotes":
            return 0

        if attr == "distinguished":
            distinguished = getattr(thing, attr, "no")
            if distinguished == "no":
                return None
            return distinguished

        if attr in ["num_reports", "report_reasons", "banned_by", "approved_by"]:
            if c.user_is_loggedin and thing.subreddit.is_moderator(c.user):
                if attr == "num_reports":
                    return thing.reported
                elif attr == "report_reasons":
                    return Report.get_reasons(thing)

                ban_info = getattr(thing, "ban_info", {})
                if attr == "banned_by":
                    banner = ban_info.get("banner") if ban_info.get("moderator_banned") else True
                    return banner if thing._spam else None
                elif attr == "approved_by":
                    return ban_info.get("unbanner") if not thing._spam else None

        return getattr(thing, attr, None)
开发者ID:JingyanZ,项目名称:reddit,代码行数:59,代码来源:jsontemplates.py


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