mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 21:23:43 +08:00
6281f5d768
CategoryBadgeSerializer and TopicCategorySerializer are too similar and are used in similar contexts. This commit merges the two into a single CategoryBadgeSerializer.
26 lines
608 B
Ruby
26 lines
608 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CategoryBadgeSerializer < ApplicationSerializer
|
|
attributes :id, :name, :slug, :color, :text_color, :read_restricted, :parent_category_id
|
|
|
|
def include_parent_category_id?
|
|
parent_category_id.present?
|
|
end
|
|
|
|
def name
|
|
if object.uncategorized?
|
|
I18n.t("uncategorized_category_name", locale: SiteSetting.default_locale)
|
|
else
|
|
object.name
|
|
end
|
|
end
|
|
|
|
def description_text
|
|
if object.uncategorized?
|
|
I18n.t("category.uncategorized_description", locale: SiteSetting.default_locale)
|
|
else
|
|
object.description_text
|
|
end
|
|
end
|
|
end
|