2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
class TopicPostCountSerializer < BasicUserSerializer
|
|
|
|
|
2017-01-18 10:37:43 -06:00
|
|
|
attributes :post_count, :primary_group_name,
|
2021-07-08 02:46:21 -05:00
|
|
|
:flair_name, :flair_url, :flair_color, :flair_bg_color,
|
2021-04-06 10:13:06 -05:00
|
|
|
:admin, :moderator, :trust_level,
|
2013-02-05 13:16:51 -06:00
|
|
|
|
|
|
|
def id
|
|
|
|
object[:user].id
|
|
|
|
end
|
|
|
|
|
|
|
|
def username
|
|
|
|
object[:user].username
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_count
|
|
|
|
object[:post_count]
|
|
|
|
end
|
|
|
|
|
2017-01-18 10:37:43 -06:00
|
|
|
def primary_group_name
|
|
|
|
return nil unless object[:user].primary_group_id
|
|
|
|
object[:user]&.primary_group&.name
|
|
|
|
end
|
|
|
|
|
2021-07-08 02:46:21 -05:00
|
|
|
def flair_name
|
|
|
|
object[:user]&.flair_group&.name
|
2017-01-18 10:37:43 -06:00
|
|
|
end
|
|
|
|
|
2021-07-08 02:46:21 -05:00
|
|
|
def flair_url
|
|
|
|
object[:user]&.flair_group&.flair_url
|
2017-01-18 10:37:43 -06:00
|
|
|
end
|
|
|
|
|
2021-07-08 02:46:21 -05:00
|
|
|
def flair_bg_color
|
|
|
|
object[:user]&.flair_group&.flair_bg_color
|
|
|
|
end
|
|
|
|
|
|
|
|
def flair_color
|
|
|
|
object[:user]&.flair_group&.flair_color
|
2017-01-18 10:37:43 -06:00
|
|
|
end
|
|
|
|
|
2021-04-06 10:13:06 -05:00
|
|
|
def include_admin?
|
|
|
|
object[:user].admin
|
|
|
|
end
|
|
|
|
|
|
|
|
def admin
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_moderator?
|
|
|
|
object[:user].moderator
|
|
|
|
end
|
|
|
|
|
|
|
|
def moderator
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def trust_level
|
|
|
|
object[:user].trust_level
|
|
|
|
end
|
|
|
|
|
2013-02-07 09:45:24 -06:00
|
|
|
end
|