Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/comment.rb
Comment thread
Bilka2 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down
19 changes: 12 additions & 7 deletions app/views/works/_work_header_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<% end %>


<% # chapter navigation %>
<%# chapter navigation %>
<% if @previous_chapter || @next_chapter %>
<li class="chapter entire"><%= link_to ts("Entire Work"), work_path(@work, :view_full_work => 'true') %></li>

Expand Down Expand Up @@ -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) %>
<li class="bookmark">
Expand All @@ -64,7 +64,7 @@
<% end %>

<li class="comments" id="show_comments_link_top">
<% # If in single chapter view, show comments for the chapter; otherwise, show the comments for the entire work %>
<%# If in single chapter view, show comments for the chapter; otherwise, show the comments for the entire work %>
<% @previous_chapter || @next_chapter ? commentable = @chapter : commentable = @work %>
<% if commentable.count_visible_comments > 0 %>
<%= show_hide_comments_link(commentable) %>
Expand All @@ -73,14 +73,19 @@
<% end %>
</li>

<% # 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? %>
<li class="comments" id="review_comments">
<%= 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) %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this use lazy lookup for the locale, so ".unreviewed_comments"?

</li>
<% 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 %>
<li class="style">
<% if Preference.disable_work_skin?(params[:style]) %>
Expand All @@ -105,7 +110,7 @@
</li>
<% 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 %>
Comment on lines -108 to +113
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an unrelated change found its way into the file, could you undo it?

<% if downloadable? && AdminSetting.current.downloads_enabled? %>
<li class="download"><noscript><h4 class="heading"><%= t(".download.heading") %></h4></noscript><button class="hidden"><%= t(".download.button") %></button>
<ul class="expandable secondary">
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3346,6 +3346,7 @@ en:
download:
button: Download
heading: Download
unreviewed_comments: "Unreviewed Comments (%{count})"
work_header_notes:
inspired_by:
other_works_inspired_by_this_one: other works inspired by this one
Expand Down
20 changes: 20 additions & 0 deletions features/comments_and_kudos/comment_moderation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,23 @@ Feature: Comment Moderation
And I view the work "Moderation"
And I follow "Unreviewed Comments (1)"
Then I should not see "Parent Thread"

Scenario: Creator marks an unreviewed comment as spam and the count updates
Given I am logged in as "spam_catcher"
And I have a work "Spam Trap"
And I edit the work "Spam Trap"
And I check "Enable comment moderation on this work"
And I press "Post Without Preview"
And I am logged out
Comment on lines +335 to +340
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be replaced with the the moderated work "Spam Trap" by "spam_catcher" step?

When I view the work "Spam Trap"
And I fill in "Comment" with "Fake spam"
And I fill in "Name" with "Spammer"
And I fill in "Email" with "spam@example.com"
And I press "Comment"
Comment on lines +342 to +345
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be replaced with the I post the comment "..." on "Spam Trap" step?

When I am logged in as "spam_catcher"
And I view the work "Spam Trap"
Then I should see "Unreviewed Comments (1)"
When I follow "Unreviewed Comments"
And I follow "Spam"
Then I should see "Unreviewed Comments (0)"
And I should not see "Fake spam"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some steps that check that for admins the count is still 1 and the comment is visible on the page for unreviewed comments but marked as spam?

Additionally, please address the comment about the indentation of the And steps

1 change: 1 addition & 0 deletions features/step_definitions/comment_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@

Given "the moderated work {string} by {string}" do |title, login|
user = ensure_user(login)
user.preference.update!(allow_co_creator_invite: true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is causing the test to fail and seems to be unrelated to this PR, could you remove it?

w = FactoryBot.create(:work, title: title, authors: [user.default_pseud])
w.update_attribute(:moderated_commenting_enabled, true)
end
Expand Down
Loading