Skip to content

Commit

Permalink
Added status of comments(updated) (#7470)
Browse files Browse the repository at this point in the history
* added status

* status message is added

* space added

* space added
  • Loading branch information
keshavsethi authored Feb 12, 2020
1 parent b648a8b commit eaf1dd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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

0 comments on commit eaf1dd0

Please sign in to comment.