mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 01:33:45 +08:00
59839e428f
Why this change? Importing theme with the `bundle` params is used mainly by `discourse_theme` CLI in the development environment. However, we do not want migrations to automatically run in the development environment and instead want the developer to be intentional about running theme migrations. As such, this commit adds support for a `skip_migrations` param when importing a theme with the `bundle` params. This commit also adds a `migrated` attribute for migrations theme fields to indicate whether a migrations theme field has been migrated or not.
46 lines
728 B
Ruby
46 lines
728 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ThemeFieldSerializer < ApplicationSerializer
|
|
attributes :name, :target, :value, :error, :type_id, :upload_id, :url, :filename, :migrated
|
|
|
|
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
|
|
|
|
def migrated
|
|
!!object.theme_settings_migration
|
|
end
|
|
|
|
def include_migrated?
|
|
target == "migrations"
|
|
end
|
|
end
|