mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-25 08:39:38 -05:00
28 lines
603 B
Ruby
28 lines
603 B
Ruby
class AdminEmailTemplateSerializer < ApplicationSerializer
|
|
attributes :id, :title, :subject, :body, :can_revert?
|
|
|
|
def id
|
|
object
|
|
end
|
|
|
|
def title
|
|
object.gsub(/.*\./, '').titleize
|
|
end
|
|
|
|
def subject
|
|
@subject ||= I18n.t("#{object}.subject_template")
|
|
end
|
|
|
|
def body
|
|
@body ||= I18n.t("#{object}.text_body_template")
|
|
end
|
|
|
|
def can_revert?
|
|
current_body, current_subject = body, subject
|
|
|
|
I18n.overrides_disabled do
|
|
return I18n.t("#{object}.subject_template") != current_subject ||
|
|
I18n.t("#{object}.text_body_template") != current_body
|
|
end
|
|
end
|
|
end
|