Browse files

Show dynamic content for moderation if a parent is not being moderate…

…d, close #868.
  • Loading branch information...
1 parent 520bdbf commit 174d161988260e1aac8b6b4f0a30f66b714575b7 @bamnet bamnet committed Feb 25, 2014
Showing with 16 additions and 3 deletions.
  1. +12 −0 app/models/feed.rb
  2. +4 −3 app/views/submissions/_index_body.html.erb
View
12 app/models/feed.rb
@@ -87,4 +87,16 @@ def self.subscribable(screen, field)
ability = Ability.new(screen)
feeds.reject { |feed| !ability.can?(:read, feed) }
end
+
+ # Figure out which submissions need to be moderated.
+ # This is a list of all the pending submissions minus dynamic content who have
+ # a parent pending moderation (since that moderation will propogate automatically).
+ def submissions_to_moderate
+ moderate = self.submissions.pending.all
+ moderate_content = moderate.collect{|s| s.content}
+ moderate.reject! do |s|
+ !s.content.parent.nil? && moderate_content.include?(s.content.parent)
+ end
+ return moderate
+ end
end
View
7 app/views/submissions/_index_body.html.erb
@@ -51,12 +51,13 @@
<%= link_to @feed.group.name, group_path(@feed.group) %>.
</div>
-<% if @can_moderate_feed and @feed.submissions.pending.count > 0 %>
+<% submissions = @feed.submissions_to_moderate %>
+<% if @can_moderate_feed and submissions.count > 0 %>
<!-- note that we do not show an alert banner when there are no pending contents; we just hide it altogether -->
<div class="clearfix default-padding">
- <h3 class="header-with-icon" style="color:#993333;"><i class="concertocon-header-pendingcontent"></i><%= t('.submissions_pending', :count => @feed.submissions.pending.count) %></h3>
+ <h3 class="header-with-icon" style="color:#993333;"><i class="concertocon-header-pendingcontent"></i><%= t('.submissions_pending', :count => submissions.count) %></h3>
<br />
- <% @feed.submissions.pending.select{|s| s.content.parent.nil?}.each do |submission| %>
+ <% submissions.each do |submission| %>
<%= render :partial => "submissions/submission_tile", :locals => { :submission => submission } %>
<% end %>
</div>

0 comments on commit 174d161

Please sign in to comment.