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, )
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, )
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) if thing.link.is_archived(thing.subreddit): suppress_reply_buttons = True show_distinguish = ( is_author and (thing.can_ban or # Moderator distinguish c.user.employee or # Admin distinguish c.user_special_distinguish)) show_sticky_comment = (feature.is_enabled('sticky_comments') and thing.is_stickyable and is_author and thing.can_ban) show_givegold = False # thing.can_gild embed_button = False show_admin_context = c.user_is_admin if thing.can_embed: 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() # CUSTOM: sub muting show_subreddit_mute = False if c.user_is_loggedin and g.sub_muting_enabled: if (isinstance(c.site, AllSR) or (isinstance(c.site, DynamicSR) and c.site.name == g.all_name)) and not thing.subreddit.is_moderator(c.user): show_subreddit_mute = True # CUSTOM - "Open chat in new tab" link for Comments # Note: Shown to all users if sub has chat enabled, doesn't check g.chat_guest_chat_enabled show_chat_link = False chat_popout_url = '' chat_enabling_post_content = g.chat_enabling_post_content if feature.is_enabled( 'chat') and thing.subreddit.chat_enabled and thing.body.find( chat_enabling_post_content) == 0: show_chat_link = True chat_client = g.chat_client chat_client_url = g.chat_client_url chat_user = c.user.pref_chat_user chat_client_user = c.user.pref_chat_client_user chat_client_password = c.user.pref_chat_client_password irc_sanitized_post_title = thing.body.replace( chat_enabling_post_content, "") irc_sanitized_post_title = re.sub( '\-+', '-', re.sub(r'[^a-zA-Z0-9]', '-', irc_sanitized_post_title))[:15].strip(' -') chat_channels = quote(g.chat_channel_name_prefix + thing.subreddit.name + '/' + irc_sanitized_post_title + g.chat_channel_name_suffix) # Note: Omitting nofocus param chat_popout_url = "{0}/?tls=true&lockchannel&autologin&user={1}&al-password={2}&autoconnect&join={3}&nick={4}&username={4}&realname={4}".format( chat_client_url, chat_client_user, chat_client_password, chat_channels, chat_user) 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, locked=thing.link.locked, suppress_reply_buttons=suppress_reply_buttons, show_report=show_report, mod_reports=thing.mod_reports, user_reports=thing.user_reports, show_distinguish=show_distinguish, distinguished=thing.distinguished, show_sticky_comment=show_sticky_comment, show_delete=show_delete, show_givegold=show_givegold, embed_button=embed_button, show_admin_context=show_admin_context, # CUSTOM show_chat_link=show_chat_link, chat_popout_url=chat_popout_url, show_subreddit_mute=show_subreddit_mute, muted=thing.muted, hide_block_user=thing.hide_block_user, )
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 c.user.employee or c.user_special_distinguish # Moderator distinguish # Admin distinguish ) show_sticky_comment = ( feature.is_enabled("sticky_comments") and thing.is_stickyable and is_author and thing.can_ban ) show_givegold = thing.can_gild embed_button = False show_admin_context = c.user_is_admin if thing.can_embed: 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, locked=thing.link.locked, 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_sticky_comment=show_sticky_comment, show_delete=show_delete, show_givegold=show_givegold, embed_button=embed_button, show_admin_context=show_admin_context, )