2013-08-07 16:04:12 -04:00
|
|
|
class StaffActionLogSerializer < ApplicationSerializer
|
|
|
|
attributes :action_name,
|
|
|
|
:details,
|
|
|
|
:context,
|
|
|
|
:ip_address,
|
|
|
|
:email,
|
2013-08-19 16:58:38 -04:00
|
|
|
:created_at,
|
|
|
|
:subject,
|
|
|
|
:previous_value,
|
|
|
|
:new_value
|
2013-08-07 16:04:12 -04:00
|
|
|
|
|
|
|
has_one :staff_user, serializer: BasicUserSerializer, embed: :objects
|
|
|
|
has_one :target_user, serializer: BasicUserSerializer, embed: :objects
|
|
|
|
|
|
|
|
def action_name
|
|
|
|
StaffActionLog.actions.key(object.action).to_s
|
|
|
|
end
|
2013-08-21 10:49:35 -04:00
|
|
|
|
|
|
|
def new_value
|
|
|
|
if object.new_value
|
|
|
|
object.new_value_is_json? ? ::JSON.parse(object.new_value) : object.new_value
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def previous_value
|
|
|
|
if object.previous_value
|
|
|
|
object.previous_value_is_json? ? ::JSON.parse(object.previous_value) : object.previous_value
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
2013-08-07 16:04:12 -04:00
|
|
|
end
|