when comments are moderated, collapse their replies

also try to show which moderator deleted the comment and the reason
This commit is contained in:
joshua stein 2012-12-18 21:30:53 -06:00
parent d64f713054
commit f7cac129b4
5 changed files with 25 additions and 18 deletions

View file

@ -337,6 +337,10 @@ ol.comments.preview {
margin: 1em 0 0 -15px;
padding: 0;
}
ol.comments.collapsed ol,
ol.comments.collapsed li {
display: none;
}
ol.search_results {
margin-left: 20px;

View file

@ -5,6 +5,8 @@ class Comment < ActiveRecord::Base
:dependent => :delete_all
belongs_to :parent_comment,
:class_name => "Comment"
has_one :moderation,
:class_name => "Moderation"
attr_accessible :comment, :moderation_reason
@ -175,14 +177,16 @@ class Comment < ActiveRecord::Base
self.is_deleted = false
if user.is_moderator? && user.id != self.user_id
self.is_moderated = true
if user.is_moderator?
self.is_moderated = false
m = Moderation.new
m.comment_id = self.id
m.moderator_user_id = user.id
m.action = "undeleted comment"
m.save
if user.id != self.user_id
m = Moderation.new
m.comment_id = self.id
m.moderator_user_id = user.id
m.action = "undeleted comment"
m.save
end
end
self.save(:validate => false)

View file

@ -34,7 +34,7 @@ class Moderation < ActiveRecord::Base
m.recipient_user_id = self.comment.user_id
m.subject = "Your comment has been moderated"
m.body = "Your comment on [#{self.comment.story.title}](" <<
"#{self.story.comments_url}) has been moderated:\n" <<
"#{self.comment.story.comments_url}) has been moderated:\n" <<
"\n" <<
"> *#{self.comment.comment}*"

View file

@ -54,11 +54,6 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<a class="comment_replier">reply</a>
<% end %>
<% if false && defined?(collapsable) && collapsable # XXX %>
|
<a href="">collapse</a>
<% end %>
<span class="reason">
<% if comment.downvotes > 0 && comment.user_id == @user.try(:id) %>
| <%= comment.vote_summary.downcase %>
@ -78,8 +73,12 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<% if comment.is_gone? %>
<p>
<span class="na">
[Comment removed by <%= comment.is_moderated? ? "moderator" :
"author" %>]
<% if comment.is_moderated? %>
[Thread removed by moderator <%= comment.moderation.try(:moderator).
try(:username) %>: <%= comment.moderation.try(:reason) %>]
<% else %>
[Comment removed by author]
<% end %>
</span>
</p>
<% else %>

View file

@ -21,7 +21,8 @@
<% indent_level = -1 %>
<% @comments.each_with_index do |comment,x| %>
<% if comment.indent_level > indent_level %>
<ol class="comments comments<%= comment.indent_level %>">
<ol class="comments comments<%= comment.indent_level %> <%=
(x > 0 && @comments[x - 1].is_moderated?) ? "collapsed" : "" %>">
<% elsif comment.indent_level < indent_level %>
<% (indent_level - comment.indent_level).times do %>
</ol>
@ -29,8 +30,7 @@
<% end %>
<%= render :partial => "comments/comment", :locals => { :story => @story,
:comment => comment, :collapsable => (@comments[x + 1].
try(:parent_comment_id).to_i == comment.id) } %>
:comment => comment } %>
<% indent_level = comment.indent_level %>
<% end %>