forked from e621ng/e621ng
[Posts]: Hide disabled comments info better (#507)
* [Posts]: Hide disabled comments info better * use method, remove nullable check, remove from api * I hate rubocop so much * missed these two
This commit is contained in:
parent
6d6282ab91
commit
6100f8f0d0
@ -72,7 +72,7 @@ class PostsDecorator < ApplicationDecorator
|
||||
post_score_icon = "#{"↑" if post.score > 0}#{"↓" if post.score < 0}#{"↕" if post.score == 0}"
|
||||
score = t.tag.span("#{post_score_icon}#{post.score}".html_safe, class: "post-score-score " + score_class(post.score))
|
||||
favs = t.tag.span("♥#{post.fav_count}".html_safe, class: 'post-score-faves')
|
||||
comments = t.tag.span "C#{post.comment_count}", class: 'post-score-comments'
|
||||
comments = t.tag.span "C#{post.visible_comment_count(CurrentUser)}", class: 'post-score-comments'
|
||||
rating = t.tag.span(post.rating.upcase, class: "post-score-rating")
|
||||
status = t.tag.span(status_flags.join(''), class: 'post-score-extras')
|
||||
t.tag.div score + favs + comments + rating + status, class: 'post-score', id: "post-score-#{post.id}"
|
||||
|
@ -91,7 +91,7 @@ module PostsHelper
|
||||
post_score_icon = "#{"↑" if post.score > 0}#{"↓" if post.score < 0}#{"↕" if post.score == 0}"
|
||||
score = tag.span("#{post_score_icon}#{post.score}".html_safe, class: "post-score-score " + score_class(post.score))
|
||||
favs = tag.span("♥#{post.fav_count}".html_safe, class: 'post-score-faves')
|
||||
comments = tag.span "C#{post.comment_count}", class: 'post-score-comments'
|
||||
comments = tag.span "C#{post.visible_comment_count(CurrentUser)}", class: 'post-score-comments'
|
||||
rating = tag.span(post.rating.upcase, class: "post-score-rating")
|
||||
status = tag.span(status_flags.join(''), class: 'post-score-extras')
|
||||
tag.div score + favs + comments + rating + status, class: 'post-score', id: "post-score-#{post.id}"
|
||||
|
@ -1772,6 +1772,10 @@ class Post < ApplicationRecord
|
||||
def flaggable_for_guidelines?
|
||||
return true if is_pending?
|
||||
return true if CurrentUser.is_privileged? && !has_tag?("grandfathered_content") && created_at.after?("2015-01-01")
|
||||
return false
|
||||
false
|
||||
end
|
||||
|
||||
def visible_comment_count(user)
|
||||
user.is_moderator? || !is_comment_disabled ? comment_count : 0
|
||||
end
|
||||
end
|
||||
|
@ -48,6 +48,9 @@ class PostEvent < ApplicationRecord
|
||||
def self.search(params)
|
||||
q = super
|
||||
|
||||
unless CurrentUser.is_moderator?
|
||||
q = q.where.not(action: [actions[:comment_disabled], actions[:comment_enabled]])
|
||||
end
|
||||
if params[:post_id].present?
|
||||
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||
end
|
||||
|
@ -169,7 +169,7 @@ class PostPresenter < Presenter
|
||||
created_at: post.created_at,
|
||||
updated_at: post.updated_at,
|
||||
fav_count: post.fav_count,
|
||||
comment_count: post.comment_count,
|
||||
comment_count: post.visible_comment_count(CurrentUser),
|
||||
change_seq: post.change_seq,
|
||||
uploader_id: post.uploader_id,
|
||||
description: post.description,
|
||||
|
@ -99,7 +99,6 @@ class PostSerializer < ActiveModel::Serializer
|
||||
note_locked: nullable_to_truthy(object.is_note_locked),
|
||||
status_locked: nullable_to_truthy(object.is_status_locked),
|
||||
rating_locked: nullable_to_truthy(object.is_rating_locked),
|
||||
comment_disabled: nullable_to_truthy(object.is_comment_disabled),
|
||||
deleted: object.is_deleted
|
||||
}
|
||||
end
|
||||
@ -137,6 +136,10 @@ class PostSerializer < ActiveModel::Serializer
|
||||
object.duration ? object.duration.to_f : nil
|
||||
end
|
||||
|
||||
def comment_count
|
||||
object.visible_comment_count(CurrentUser)
|
||||
end
|
||||
|
||||
attributes :id, :created_at, :updated_at, :file, :preview, :sample, :score, :tags, :locked_tags, :change_seq, :flags,
|
||||
:rating, :fav_count, :sources, :pools, :relationships, :approver_id, :uploader_id, :description,
|
||||
:comment_count, :is_favorited, :has_notes, :duration
|
||||
|
Loading…
Reference in New Issue
Block a user