diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 05b7ce921a..be6f066fd3 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -344,10 +344,9 @@ def index end def unreviewed - @comments = @commentable.find_all_comments - .unreviewed_only - .for_display - .page(params[:page]) + @comments = @commentable.find_all_comments.unreviewed_only + @comments = @comments.not_spam unless logged_in_as_admin? + @comments = @comments.for_display.page(params[:page]) end # GET /comments/1 diff --git a/app/models/comment.rb b/app/models/comment.rb index a46daf221c..91d15a1358 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -91,6 +91,7 @@ def edited_spam scope :top_level, -> { where.not(commentable_type: "Comment") } scope :include_pseud, -> { includes(:pseud) } scope :not_deleted, -> { where(is_deleted: false) } + scope :not_spam, -> { where(approved: true) } scope :reviewed, -> { where(unreviewed: false) } scope :unreviewed_only, -> { where(unreviewed: true) } diff --git a/app/views/works/_work_header_navigation.html.erb b/app/views/works/_work_header_navigation.html.erb index 363a6078dd..0e74060158 100644 --- a/app/views/works/_work_header_navigation.html.erb +++ b/app/views/works/_work_header_navigation.html.erb @@ -12,7 +12,7 @@ <% end %> - <% # chapter navigation %> + <%# chapter navigation %> <% if @previous_chapter || @next_chapter %>
  • <%= link_to ts("Entire Work"), work_path(@work, :view_full_work => 'true') %>
  • @@ -44,7 +44,7 @@ <% end %> - <% # for users, bookmark and mark to read later %> + <%# for users, bookmark and mark to read later %> <% if current_user.is_a?(User) %> <% @bookmark ||= bookmark_if_exists(@work) %>
  • @@ -64,7 +64,7 @@ <% end %>
  • - <% # for author or admin, review comments if moderating them %> + <%# for author or admin, review comments if moderating them %> <% if (logged_in_as_admin? || (current_user && current_user.is_author_of?(@work))) && @work.find_all_comments.unreviewed_only.exists? %>
  • - <%= link_to ts("Unreviewed Comments") + " (" + @work.find_all_comments.unreviewed_only.count.to_s + ")" , unreviewed_work_comments_path(@work) %> + <% unreviewed_count = if logged_in_as_admin? + @work.find_all_comments.unreviewed_only.count + else + @work.find_all_comments.unreviewed_only.not_spam.count + end %> + <%= link_to t("works.work_header_navigation.unreviewed_comments", count: unreviewed_count), unreviewed_work_comments_path(@work) %>
  • <% end %> - <% # allow user to disable style on work if it has been customized %> + <%# allow user to disable style on work if it has been customized %> <% if @work.work_skin %>
  • <% if Preference.disable_work_skin?(params[:style]) %> @@ -105,7 +110,7 @@
  • <% end %> - <%# The li, noscript, and button tags MUST be on the same line here to avoid the behavior described in https://otwarchive.atlassian.net/browse/AO3-4629?focusedCommentId=372231 %> + <%# The li, noscript, and button tags MUST be on the same line here %> <% if downloadable? && AdminSetting.current.downloads_enabled? %>