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