Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added status of comments(updated) #7470

Merged
merged 4 commits into from
Feb 12, 2020
Merged
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
12 changes: 12 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ def parent
aid.zero? ? node : answer&.node
end

def status_value
if status == 0
'Banned'
elsif status == 1
'Normal'
elsif status == 4
'Moderated'
else
'Not Defined'
end
end

def mentioned_users
usernames = comment.scan(Callouts.const_get(:FINDER))
User.where(username: usernames.map { |m| m[1] }).distinct
Expand Down
2 changes: 2 additions & 0 deletions app/views/comments/_comments.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
<td><%= distance_of_time_in_words(comment.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %></td>
<td>
<% if comment.status == 4 && current_user &. can_moderate? %>
Status: <%= comment.status_value %>
<a class="btn btn-outline-secondary btn-sm" href="/admin/publish_comment/<%= comment.id %>"><%= translation('dashboard.moderate.approve') %></a>
<a class="btn btn-outline-secondary btn-sm" href="/admin/mark_comment_spam/<%= comment.id %>"><%= translation('dashboard.moderate.spam') %></a>
<% elsif current_user &. can_moderate? %>
Status: <%= comment.status_value %>
<a rel="tooltip" title="Mark as spam" class="btn btn-sm btn-outline-secondary btn-flag-spam-<%= comment.id %>" data-confirm="Are you sure? The user will no longer be able to log in or publish, and their content will be hidden except comments." href="/admin/mark_comment_spam/<%= comment.id %>">
<i class="fa fa-ban"></i>
</a>
Expand Down