Example #1
0
    def __init__(self, thing, delete = True, report = True):
        # is the current user the author?
        is_author = thing.is_author

        # if they are the author, can they edit it?
        thing_editable = getattr(thing, 'editable', True)
        thing_takendown = getattr(thing, 'admin_takedown', False)
        editable = is_author and thing_editable and not thing_takendown

        # 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
        suppress_reply_buttons = getattr(thing, 'suppress_reply_buttons', False)

        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

        embed_button = False

        from r2.lib import embeds
        if thing.can_embed and embeds.embeddable_sr(thing):
            embed_button = JsButton("embed",
                css_class="embed-comment",
                data={
                    "media": g.media_domain or g.domain,
                    "comment": thing.permalink,
                    "link": thing.link.make_permalink(thing.subreddit),
                    "title": thing.link.title,
                    "root": ("true" if thing.parent_id is None else "false"),
                })

            embed_button.build()

        PrintableButtons.__init__(self, "commentbuttons", thing,
                                  can_save=thing.can_save,
                                  is_author = is_author, 
                                  profilepage = c.profilepage,
                                  permalink = thing.permalink,
                                  saved = thing.saved,
                                  editable = editable,
                                  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,
                                  suppress_reply_buttons = suppress_reply_buttons,
                                  show_report=show_report,
                                  mod_reports=thing.mod_reports,
                                  user_reports=thing.user_reports,
                                  show_distinguish = show_distinguish,
                                  show_delete = show_delete,
                                  show_givegold=show_givegold,
                                  embed_button=embed_button,
        )
Example #2
0
    def __init__(self, thing, delete = True, report = True):
        # is the current user the author?
        is_author = thing.is_author

        # if they are the author, can they edit it?
        thing_editable = getattr(thing, 'editable', True)
        thing_takendown = getattr(thing, 'admin_takedown', False)
        editable = is_author and thing_editable and not thing_takendown

        # 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
        suppress_reply_buttons = getattr(thing, 'suppress_reply_buttons', False)

        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

        embed_button = False

        from r2.lib import embeds
        if thing.can_embed and embeds.embeddable_sr(thing):
            embed_button = JsButton("embed",
                css_class="embed-comment",
                data={
                    "media": g.media_domain or g.domain,
                    "comment": thing.permalink,
                    "link": thing.link.make_permalink(thing.subreddit),
                    "title": thing.link.title,
                    "root": ("true" if thing.parent_id is None else "false"),
                })

            embed_button.build()

        PrintableButtons.__init__(self, "commentbuttons", thing,
                                  is_author = is_author, 
                                  profilepage = c.profilepage,
                                  permalink = thing.permalink,
                                  saved = thing.saved,
                                  editable = editable,
                                  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,
                                  suppress_reply_buttons = suppress_reply_buttons,
                                  show_report=show_report,
                                  mod_reports=thing.mod_reports,
                                  user_reports=thing.user_reports,
                                  show_distinguish = show_distinguish,
                                  show_delete = show_delete,
                                  show_givegold=show_givegold,
                                  embed_button=embed_button,
        )