Permalink
Browse files

don't collapse moderated threads, remove them entirely

  • Loading branch information...
jcs committed Dec 30, 2012
1 parent 1031ea8 commit 19ba94fd31cef2de1f1746b25a47e9a6b18a37b2
Showing with 31 additions and 9 deletions.
  1. +29 −1 app/models/comment.rb
  2. +1 −6 app/views/comments/_comment.html.erb
  3. +1 −2 app/views/stories/show.html.erb
View
@@ -99,6 +99,16 @@ def is_gone?
is_deleted? || is_moderated?
end
def gone_text
if self.is_moderated?
"Thread removed by moderator " <<
self.moderation.try(:moderator).try(:username).to_s << ": " <<
(self.moderation.try(:reason) || "No reason given")
else
"Comment removed by author"
end
end
def mark_submitter
Keystore.increment_value_for("user:#{self.user_id}:comments_posted")
end
@@ -304,9 +314,27 @@ def self.ordered_for_story_or_thread_for_user(story_id, thread_id, user)
new_ordered.push c
end
# for moderated threads, remove the entire sub-tree at the moderation point
do_reject = false
deleted_indent_level = 0
new_ordered.reject!{|c|
if do_reject && (c.indent_level > deleted_indent_level)
true
else
if c.is_moderated?
do_reject = true
deleted_indent_level = c.indent_level
else
do_reject = false
end
false
end
}
new_ordered
end
def is_editable_by_user?(user)
if user && user.id == self.user_id
if self.is_moderated?
@@ -73,12 +73,7 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<% if comment.is_gone? %>
<p>
<span class="na">
<% if comment.is_moderated? %>
[Thread removed by moderator <%= comment.moderation.try(:moderator).
try(:username) %>: <%= comment.moderation.try(:reason) %>]
<% else %>
[Comment removed by author]
<% end %>
[<%= comment.gone_text %>]
</span>
</p>
<% else %>
@@ -21,8 +21,7 @@
<% indent_level = -1 %>
<% @comments.each_with_index do |comment,x| %>
<% if comment.indent_level > indent_level %>
<ol class="comments comments<%= comment.indent_level %> <%=
(x > 0 && @comments[x - 1].is_moderated?) ? "collapsed" : "" %>">
<ol class="comments comments<%= comment.indent_level %>">
<% elsif comment.indent_level < indent_level %>
<% (indent_level - comment.indent_level).times do %>
</ol>

0 comments on commit 19ba94f

Please sign in to comment.