FIX: wraps overrides in reloadable_patch
This commit is contained in:
parent
335b613e52
commit
020ed3cd6d
84
plugin.rb
84
plugin.rb
|
@ -36,53 +36,53 @@ after_initialize do
|
||||||
|
|
||||||
load File.expand_path('../app/jobs/onceoff/voting_ensure_consistency.rb', __FILE__)
|
load File.expand_path('../app/jobs/onceoff/voting_ensure_consistency.rb', __FILE__)
|
||||||
|
|
||||||
require_dependency 'basic_category_serializer'
|
reloadable_patch do |plugin|
|
||||||
class ::BasicCategorySerializer
|
require_dependency 'basic_category_serializer'
|
||||||
attributes :can_vote
|
class ::BasicCategorySerializer
|
||||||
|
attributes :can_vote
|
||||||
|
|
||||||
def include_can_vote?
|
def include_can_vote?
|
||||||
Category.can_vote?(object.id)
|
Category.can_vote?(object.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_vote
|
def can_vote
|
||||||
true
|
true
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
require_dependency 'post_serializer'
|
|
||||||
class ::PostSerializer
|
|
||||||
attributes :can_vote
|
|
||||||
|
|
||||||
def include_can_vote?
|
|
||||||
object.post_number == 1 && object.topic && object.topic.can_vote?
|
|
||||||
end
|
|
||||||
|
|
||||||
def can_vote
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require_dependency 'topic_view_serializer'
|
|
||||||
class ::TopicViewSerializer
|
|
||||||
attributes :can_vote, :vote_count, :user_voted
|
|
||||||
|
|
||||||
def can_vote
|
|
||||||
object.topic.can_vote?
|
|
||||||
end
|
|
||||||
|
|
||||||
def vote_count
|
|
||||||
object.topic.vote_count
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_voted
|
|
||||||
if scope.user
|
|
||||||
object.topic.user_voted(scope.user)
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require_dependency 'post_serializer'
|
||||||
|
class ::PostSerializer
|
||||||
|
attributes :can_vote
|
||||||
|
|
||||||
|
def include_can_vote?
|
||||||
|
object.post_number == 1 && object.topic && object.topic.can_vote?
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_vote
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require_dependency 'topic_view_serializer'
|
||||||
|
class ::TopicViewSerializer
|
||||||
|
attributes :can_vote, :vote_count, :user_voted
|
||||||
|
|
||||||
|
def can_vote
|
||||||
|
object.topic.can_vote?
|
||||||
|
end
|
||||||
|
|
||||||
|
def vote_count
|
||||||
|
object.topic.vote_count
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_voted
|
||||||
|
if scope.user
|
||||||
|
object.topic.user_voted(scope.user)
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_to_serializer(:topic_list_item, :vote_count) { object.vote_count }
|
add_to_serializer(:topic_list_item, :vote_count) { object.vote_count }
|
||||||
|
|
Loading…
Reference in New Issue