discourse/app/serializers/about_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.6 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2014-08-11 15:59:00 -05:00
class AboutSerializer < ApplicationSerializer
class CategoryAboutSerializer < CategoryBadgeSerializer
has_one :parent_category, serializer: CategoryBadgeSerializer, root: :categories
end
class UserAboutSerializer < BasicUserSerializer
attributes :title, :last_seen_at
end
class AboutCategoryModsSerializer < ApplicationSerializer
has_one :category, serializer: CategoryAboutSerializer
has_many :moderators, serializer: UserAboutSerializer, root: :users
end
has_many :moderators, serializer: UserAboutSerializer, root: :users
has_many :admins, serializer: UserAboutSerializer, root: :users
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,
:extended_site_description,
:banner_image,
:site_creation_date,
2014-08-11 17:15:35 -05:00
:title,
:locale,
:version,
:https,
:can_see_about_stats,
:contact_url,
:contact_email
def include_stats?
can_see_about_stats
end
2015-07-06 23:52:19 -05:00
def stats
object.class.fetch_cached_stats
2015-07-06 23:52:19 -05:00
end
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