Merge pull request #128 from medialab-prado/comments-count

Add draft versions comments count to admin views
This commit is contained in:
Amaia Castro
2017-03-10 13:10:49 +01:00
committed by GitHub
3 changed files with 6 additions and 2 deletions

View File

@@ -26,4 +26,8 @@ class Legislation::DraftVersion < ActiveRecord::Base
def display_title def display_title
status == 'draft' ? "#{title} *" : title status == 'draft' ? "#{title} *" : title
end end
def total_comments
annotations.sum(:comments_count)
end
end end

View File

@@ -64,7 +64,7 @@ class Legislation::Process < ActiveRecord::Base
end end
def total_comments def total_comments
questions.sum(:comments_count) questions.sum(:comments_count) + draft_versions.map(&:total_comments).sum
end end
def status def status

View File

@@ -41,7 +41,7 @@
</td> </td>
<td><%= draft_version.created_at.to_date %></td> <td><%= draft_version.created_at.to_date %></td>
<td><%= draft_version.status %> <%= link_to "(#{t('.preview')})", legislation_process_draft_version_path(@process, draft_version) if draft_version.status == 'draft' %></td> <td><%= draft_version.status %> <%= link_to "(#{t('.preview')})", legislation_process_draft_version_path(@process, draft_version) if draft_version.status == 'draft' %></td>
<td><%#= draft_version.comments %></td> <td><%= draft_version.total_comments %></td>
<td><%= draft_version.final_version %></td> <td><%= draft_version.final_version %></td>
</tr> </tr>
<% end %> <% end %>