2019-01-04 01:03:01 +08:00
|
|
|
# Deprecated, should be removed once users have sufficient opportunity to do so
|
2015-04-11 05:00:50 +08:00
|
|
|
class QueuedPostSerializer < ApplicationSerializer
|
2015-04-15 02:21:02 +08:00
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
attributes(
|
|
|
|
:id,
|
|
|
|
:queue,
|
|
|
|
:user_id,
|
|
|
|
:state,
|
|
|
|
:topic_id,
|
|
|
|
:approved_by_id,
|
|
|
|
:rejected_by_id,
|
|
|
|
:raw,
|
|
|
|
:post_options,
|
|
|
|
:created_at,
|
|
|
|
:category_id,
|
|
|
|
:can_delete_user
|
|
|
|
)
|
|
|
|
has_one :created_by, serializer: AdminUserListSerializer, root: :users
|
2015-04-15 02:21:02 +08:00
|
|
|
has_one :topic, serializer: BasicTopicSerializer
|
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
def queue
|
|
|
|
'default'
|
2015-04-16 03:29:37 +08:00
|
|
|
end
|
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
def user_id
|
|
|
|
object.created_by_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def state
|
|
|
|
object.status + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def approved_by_id
|
|
|
|
who_did(:approved)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rejected_by_id
|
|
|
|
who_did(:rejected)
|
|
|
|
end
|
|
|
|
|
|
|
|
def raw
|
|
|
|
object.payload['raw']
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_options
|
|
|
|
object.payload.except('raw')
|
2015-04-16 03:29:37 +08:00
|
|
|
end
|
|
|
|
|
2015-05-20 00:19:25 +08:00
|
|
|
def can_delete_user
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_can_delete_user?
|
2019-01-04 01:03:01 +08:00
|
|
|
created_by && created_by.trust_level == TrustLevel[0]
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def who_did(status)
|
|
|
|
object.
|
|
|
|
reviewable_histories.
|
|
|
|
where(
|
|
|
|
reviewable_history_type: ReviewableHistory.types[:transitioned],
|
|
|
|
status: Reviewable.statuses[status]
|
|
|
|
).
|
|
|
|
order(:created_at)
|
|
|
|
.last&.created_by_id
|
2015-05-20 00:19:25 +08:00
|
|
|
end
|
|
|
|
|
2015-04-11 05:00:50 +08:00
|
|
|
end
|