mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
427d54b2b0
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. We no longer need to use Rails "require_dependency" anywhere and instead can just use standard Ruby patterns to require files. This is a far reaching change and we expect some followups here.
68 lines
1.1 KiB
Ruby
68 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class NewPostResultSerializer < ApplicationSerializer
|
|
attributes :action,
|
|
:post,
|
|
:errors,
|
|
:success,
|
|
:pending_count,
|
|
:reason
|
|
|
|
has_one :pending_post, serializer: TopicPendingPostSerializer, root: false, embed: :objects
|
|
|
|
def post
|
|
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
|
|
post_serializer.draft_sequence = DraftSequence.current(scope.user, object.post.topic.draft_key)
|
|
post_serializer.as_json
|
|
end
|
|
|
|
def include_post?
|
|
object.post.present?
|
|
end
|
|
|
|
def success
|
|
true
|
|
end
|
|
|
|
def include_success?
|
|
@object.success?
|
|
end
|
|
|
|
def errors
|
|
object.errors.full_messages
|
|
end
|
|
|
|
def include_errors?
|
|
!object.errors.empty?
|
|
end
|
|
|
|
def reason
|
|
object.reason
|
|
end
|
|
|
|
def include_reason?
|
|
scope.is_staff? && reason.present?
|
|
end
|
|
|
|
def action
|
|
object.action
|
|
end
|
|
|
|
def pending_count
|
|
object.pending_count
|
|
end
|
|
|
|
def pending_post
|
|
object.reviewable
|
|
end
|
|
|
|
def include_pending_post?
|
|
object.reviewable.present?
|
|
end
|
|
|
|
def include_pending_count?
|
|
pending_count.present?
|
|
end
|
|
|
|
end
|