2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-08-12 04:59:00 +08:00
|
|
|
class AboutSerializer < ApplicationSerializer
|
2024-05-11 01:11:43 +08:00
|
|
|
class CategoryAboutSerializer < CategoryBadgeSerializer
|
|
|
|
has_one :parent_category, serializer: CategoryBadgeSerializer, root: :categories
|
|
|
|
end
|
|
|
|
|
2019-01-15 19:55:22 +08:00
|
|
|
class UserAboutSerializer < BasicUserSerializer
|
|
|
|
attributes :title, :last_seen_at
|
|
|
|
end
|
|
|
|
|
2019-07-31 21:46:58 +08:00
|
|
|
class AboutCategoryModsSerializer < ApplicationSerializer
|
2024-05-11 01:11:43 +08:00
|
|
|
has_one :category, serializer: CategoryAboutSerializer
|
|
|
|
has_many :moderators, serializer: UserAboutSerializer, root: :users
|
2019-07-31 21:46:58 +08:00
|
|
|
end
|
|
|
|
|
2024-05-11 01:11:43 +08:00
|
|
|
has_many :moderators, serializer: UserAboutSerializer, root: :users
|
|
|
|
has_many :admins, serializer: UserAboutSerializer, root: :users
|
2019-07-31 21:46:58 +08:00
|
|
|
has_many :category_moderators, serializer: AboutCategoryModsSerializer, embed: :objects
|
2014-08-12 04:59:00 +08:00
|
|
|
|
2014-08-12 06:15:35 +08:00
|
|
|
attributes :stats,
|
|
|
|
:description,
|
|
|
|
:title,
|
|
|
|
:locale,
|
2014-11-24 14:54:17 +08:00
|
|
|
:version,
|
2020-05-23 12:56:13 +08:00
|
|
|
:https,
|
2021-05-19 14:15:24 +08:00
|
|
|
:can_see_about_stats,
|
|
|
|
:contact_url,
|
2024-04-04 02:52:28 +08:00
|
|
|
:contact_email
|
2020-05-23 12:56:13 +08:00
|
|
|
|
|
|
|
def include_stats?
|
|
|
|
can_see_about_stats
|
|
|
|
end
|
2015-07-07 12:52:19 +08:00
|
|
|
|
|
|
|
def stats
|
2023-11-10 04:44:05 +08:00
|
|
|
object.class.fetch_cached_stats
|
2015-07-07 12:52:19 +08:00
|
|
|
end
|
2021-05-19 14:15:24 +08:00
|
|
|
|
|
|
|
def include_contact_url?
|
|
|
|
can_see_site_contact_details
|
|
|
|
end
|
|
|
|
|
|
|
|
def contact_url
|
|
|
|
SiteSetting.contact_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_contact_email?
|
|
|
|
can_see_site_contact_details
|
|
|
|
end
|
|
|
|
|
|
|
|
def contact_email
|
|
|
|
SiteSetting.contact_email
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_see_about_stats
|
|
|
|
scope.can_see_about_stats?
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_see_site_contact_details
|
|
|
|
scope.can_see_site_contact_details?
|
|
|
|
end
|
2014-08-12 04:59:00 +08:00
|
|
|
end
|