2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-05-10 02:47:47 -04:00
|
|
|
class BasicCategorySerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:name,
|
|
|
|
:color,
|
|
|
|
:text_color,
|
|
|
|
:slug,
|
|
|
|
:topic_count,
|
2014-05-28 13:33:39 -04:00
|
|
|
:post_count,
|
2015-08-27 13:14:59 -04:00
|
|
|
:position,
|
2013-05-10 02:47:47 -04:00
|
|
|
:description,
|
2014-10-22 00:48:18 -04:00
|
|
|
:description_text,
|
2019-12-19 10:09:45 -05:00
|
|
|
:description_excerpt,
|
2013-05-10 02:47:47 -04:00
|
|
|
:topic_url,
|
2013-07-16 01:44:07 -04:00
|
|
|
:read_restricted,
|
2013-10-23 13:29:20 -04:00
|
|
|
:permission,
|
2014-04-17 05:17:39 -04:00
|
|
|
:parent_category_id,
|
2014-06-27 15:35:25 -04:00
|
|
|
:notification_level,
|
2015-07-02 16:18:59 -04:00
|
|
|
:can_edit,
|
2015-09-02 17:46:04 -04:00
|
|
|
:topic_template,
|
2023-12-08 05:01:08 -05:00
|
|
|
:has_children,
|
2024-04-25 09:47:45 -04:00
|
|
|
:subcategory_count,
|
2016-11-01 12:18:31 -04:00
|
|
|
:sort_order,
|
2017-02-21 18:08:09 -05:00
|
|
|
:sort_ascending,
|
2017-03-01 12:03:12 -05:00
|
|
|
:show_subcategory_list,
|
2017-03-02 10:56:04 -05:00
|
|
|
:num_featured_topics,
|
2017-03-08 11:31:30 -05:00
|
|
|
:default_view,
|
2017-03-22 16:54:12 -04:00
|
|
|
:subcategory_list_style,
|
2018-03-28 14:40:26 -04:00
|
|
|
:default_top_period,
|
2020-06-03 15:26:56 -04:00
|
|
|
:default_list_filter,
|
2018-07-16 04:10:22 -04:00
|
|
|
:minimum_required_tags,
|
2019-03-16 07:48:57 -04:00
|
|
|
:navigate_to_first_post_after_read,
|
|
|
|
:custom_fields
|
2013-05-10 02:47:47 -04:00
|
|
|
|
2016-12-02 02:15:34 -05:00
|
|
|
has_one :uploaded_logo, embed: :object, serializer: CategoryUploadSerializer
|
2022-10-07 11:00:44 -04:00
|
|
|
has_one :uploaded_logo_dark, embed: :object, serializer: CategoryUploadSerializer
|
2016-12-02 02:15:34 -05:00
|
|
|
has_one :uploaded_background, embed: :object, serializer: CategoryUploadSerializer
|
2023-10-20 08:48:06 -04:00
|
|
|
has_one :uploaded_background_dark, embed: :object, serializer: CategoryUploadSerializer
|
2016-12-02 02:15:34 -05:00
|
|
|
|
2013-10-23 14:40:39 -04:00
|
|
|
def include_parent_category_id?
|
|
|
|
parent_category_id
|
|
|
|
end
|
2014-06-24 17:27:29 -04:00
|
|
|
|
2019-03-04 15:15:38 -05:00
|
|
|
def name
|
|
|
|
if object.uncategorized?
|
|
|
|
I18n.t("uncategorized_category_name", locale: SiteSetting.default_locale)
|
2023-01-09 07:20:10 -05:00
|
|
|
else
|
2019-03-04 15:15:38 -05:00
|
|
|
object.name
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2019-03-04 15:15:38 -05:00
|
|
|
end
|
|
|
|
|
2020-01-03 11:10:06 -05:00
|
|
|
def description_text
|
|
|
|
if object.uncategorized?
|
|
|
|
I18n.t("category.uncategorized_description", locale: SiteSetting.default_locale)
|
2023-01-09 07:20:10 -05:00
|
|
|
else
|
2020-01-03 11:10:06 -05:00
|
|
|
object.description_text
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2020-01-03 11:10:06 -05:00
|
|
|
end
|
|
|
|
|
2014-06-24 17:27:29 -04:00
|
|
|
def description
|
2019-03-04 15:15:38 -05:00
|
|
|
if object.uncategorized?
|
|
|
|
I18n.t("category.uncategorized_description", locale: SiteSetting.default_locale)
|
2023-01-09 07:20:10 -05:00
|
|
|
else
|
2019-03-04 15:15:38 -05:00
|
|
|
object.description
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2014-06-24 17:27:29 -04:00
|
|
|
end
|
2014-08-12 13:30:28 -04:00
|
|
|
|
2020-01-03 11:46:18 -05:00
|
|
|
def description_excerpt
|
|
|
|
if object.uncategorized?
|
|
|
|
I18n.t("category.uncategorized_description", locale: SiteSetting.default_locale)
|
2023-01-09 07:20:10 -05:00
|
|
|
else
|
2020-01-03 11:46:18 -05:00
|
|
|
object.description_excerpt
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2020-01-03 11:46:18 -05:00
|
|
|
end
|
|
|
|
|
2014-08-12 13:30:28 -04:00
|
|
|
def can_edit
|
|
|
|
true
|
|
|
|
end
|
2014-09-09 09:32:58 -04:00
|
|
|
|
2014-08-12 13:30:28 -04:00
|
|
|
def include_can_edit?
|
|
|
|
scope && scope.can_edit?(object)
|
|
|
|
end
|
|
|
|
|
2015-12-13 05:26:16 -05:00
|
|
|
def notification_level
|
2016-02-03 07:58:59 -05:00
|
|
|
object.notification_level
|
2015-12-13 05:26:16 -05:00
|
|
|
end
|
2019-03-16 07:48:57 -04:00
|
|
|
|
|
|
|
def custom_fields
|
|
|
|
object.preloaded_custom_fields
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_custom_fields?
|
|
|
|
custom_fields.present?
|
|
|
|
end
|
2013-05-10 02:47:47 -04:00
|
|
|
end
|