mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-05 03:00:15 -04:00
Display removed selftext as "[deleted]".
When a self-post is manually removed (via the "remove" button) by an admin or a moderator, the text of that self post will be displayed as "[deleted]" unless the viewer is an admin, mod of the subreddit the post is in, or the author of the content.
This commit is contained in:
@@ -2670,12 +2670,33 @@ class MediaEmbed(Templated):
|
||||
"""The actual rendered iframe for a media child"""
|
||||
pass
|
||||
|
||||
|
||||
class SelfTextChild(LinkChild):
|
||||
css_style = "selftext"
|
||||
|
||||
def _should_expunge_selftext(self):
|
||||
verdict = getattr(self.link, "verdict", "")
|
||||
if verdict not in ("admin-removed", "mod-removed"):
|
||||
return False
|
||||
if not c.user_is_loggedin:
|
||||
return True
|
||||
if c.user_is_admin:
|
||||
return False
|
||||
if c.user == self.link.author:
|
||||
return False
|
||||
|
||||
sr = Subreddit._byID(self.link.sr_id, stale=True)
|
||||
if sr.is_moderator(c.user):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def content(self):
|
||||
expunged = self._should_expunge_selftext()
|
||||
u = UserText(self.link, self.link.selftext,
|
||||
editable = c.user == self.link.author,
|
||||
nofollow = self.nofollow)
|
||||
nofollow = self.nofollow,
|
||||
expunged=expunged)
|
||||
return u.render()
|
||||
|
||||
class UserText(CachedTemplate):
|
||||
@@ -2691,7 +2712,8 @@ class UserText(CachedTemplate):
|
||||
post_form = 'editusertext',
|
||||
cloneable = False,
|
||||
extra_css = '',
|
||||
name = "text"):
|
||||
name = "text",
|
||||
expunged=False):
|
||||
|
||||
css_class = "usertext"
|
||||
if cloneable:
|
||||
@@ -2714,7 +2736,8 @@ class UserText(CachedTemplate):
|
||||
post_form = post_form,
|
||||
cloneable = cloneable,
|
||||
css_class = css_class,
|
||||
name = name)
|
||||
name = name,
|
||||
expunged=expunged)
|
||||
|
||||
class MediaEmbedBody(CachedTemplate):
|
||||
"""What's rendered inside the iframe that contains media objects"""
|
||||
|
||||
@@ -47,10 +47,14 @@
|
||||
<input type="hidden" name="thing_id" value="${thing.fullname or ''}"/>
|
||||
|
||||
%if not thing.creating:
|
||||
% if not thing.expunged:
|
||||
<div class="usertext-body">
|
||||
${unsafe(safemarkdown(thing.text, nofollow = thing.nofollow,
|
||||
target = thing.target))}
|
||||
</div>
|
||||
% else:
|
||||
<em>${_("[deleted]")}</em> 
|
||||
% endif
|
||||
%endif
|
||||
|
||||
%if thing.editable or thing.creating:
|
||||
|
||||
@@ -48,8 +48,12 @@
|
||||
|
||||
%if not thing.creating:
|
||||
<div class="usertext-body">
|
||||
% if not thing.expunged:
|
||||
${unsafe(safemarkdown(thing.text, nofollow = thing.nofollow,
|
||||
target = thing.target))}
|
||||
% else:
|
||||
<em>${_("[deleted]")}</em> 
|
||||
% endif
|
||||
</div>
|
||||
%endif
|
||||
|
||||
|
||||
@@ -24,8 +24,12 @@
|
||||
%>
|
||||
|
||||
%if thing.text:
|
||||
%if not thing.expunged:
|
||||
<div class="usertext-body">
|
||||
${unsafe(safemarkdown(thing.text, nofollow = thing.nofollow,
|
||||
target = thing.target))}
|
||||
</div>
|
||||
%endif
|
||||
%else:
|
||||
<em>${_("[deleted]")}</em> 
|
||||
%endif
|
||||
%endif
|
||||
|
||||
Reference in New Issue
Block a user