2015-11-12 16:08:19 -05:00
|
|
|
class AdminEmailTemplateSerializer < ApplicationSerializer
|
2015-11-20 12:30:04 -05:00
|
|
|
attributes :id, :title, :subject, :body, :can_revert?
|
2015-11-12 16:08:19 -05:00
|
|
|
|
|
|
|
def id
|
|
|
|
object
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
object.gsub(/.*\./, '').titleize
|
|
|
|
end
|
|
|
|
|
|
|
|
def subject
|
2015-11-20 12:30:04 -05:00
|
|
|
@subject ||= I18n.t("#{object}.subject_template")
|
2015-11-12 16:08:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def body
|
2015-11-20 12:30:04 -05:00
|
|
|
@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
|
2015-11-12 16:08:19 -05:00
|
|
|
end
|
|
|
|
end
|