Skip to content

Commit

Permalink
Show dynamic content for moderation if a parent is not being moderated,
Browse files Browse the repository at this point in the history
close #868.
  • Loading branch information
bamnet committed Feb 26, 2014
1 parent 520bdbf commit 174d161
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions app/models/feed.rb
Expand Up @@ -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
7 changes: 4 additions & 3 deletions app/views/submissions/_index_body.html.erb
Expand Up @@ -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>
Expand Down

0 comments on commit 174d161

Please sign in to comment.