mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 07:36:28 +08:00
012aaf0ba3
The value field of ThemeField is only used when viewing a diff in the staff action logs and local theme editing. value is being serialized into the theme index as well, which is not used. It's a huge amount of JSON that we can cut by removing it. This also breaks up the various theme serializers into separate classes so they autoload properly (or at least restart the server on edit)
38 lines
599 B
Ruby
38 lines
599 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ThemeFieldSerializer < ApplicationSerializer
|
|
attributes :name, :target, :value, :error, :type_id, :upload_id, :url, :filename
|
|
|
|
def include_url?
|
|
object.upload
|
|
end
|
|
|
|
def include_upload_id?
|
|
object.upload
|
|
end
|
|
|
|
def include_filename?
|
|
object.upload
|
|
end
|
|
|
|
def url
|
|
object.upload&.url
|
|
end
|
|
|
|
def filename
|
|
object.upload&.original_filename
|
|
end
|
|
|
|
def include_value?
|
|
@options[:include_value] || false
|
|
end
|
|
|
|
def target
|
|
Theme.lookup_target(object.target_id)&.to_s
|
|
end
|
|
|
|
def include_error?
|
|
object.error.present?
|
|
end
|
|
end
|