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