mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 01:43:45 +08:00
22 lines
419 B
Ruby
22 lines
419 B
Ruby
class TopListSerializer < ApplicationSerializer
|
|
|
|
attributes :can_create_topic,
|
|
:draft,
|
|
:draft_key,
|
|
:draft_sequence
|
|
|
|
def can_create_topic
|
|
scope.can_create?(Topic)
|
|
end
|
|
|
|
TopTopic.periods.each do |period|
|
|
attribute period
|
|
|
|
define_method(period) do
|
|
TopicListSerializer.new(object.send(period), scope: scope).as_json if object.send(period)
|
|
end
|
|
|
|
end
|
|
|
|
end
|