2013-06-28 13:55:34 -04:00
|
|
|
# The most basic attributes of a topic that we need to create a link for it.
|
|
|
|
class BasicPostSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:name,
|
|
|
|
:username,
|
|
|
|
:avatar_template,
|
|
|
|
:created_at,
|
|
|
|
:cooked
|
|
|
|
|
|
|
|
def name
|
2013-09-03 17:19:29 -04:00
|
|
|
object.user.try(:name)
|
2013-06-28 13:55:34 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def username
|
2013-09-03 17:19:29 -04:00
|
|
|
object.user.try(:username)
|
2013-06-28 13:55:34 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def avatar_template
|
2013-09-03 17:19:29 -04:00
|
|
|
object.user.try(:avatar_template)
|
2013-06-28 13:55:34 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def cooked
|
|
|
|
if object.hidden && !scope.is_staff?
|
|
|
|
if scope.current_user && object.user_id == scope.current_user.id
|
|
|
|
I18n.t('flagging.you_must_edit')
|
|
|
|
else
|
|
|
|
I18n.t('flagging.user_must_edit')
|
|
|
|
end
|
|
|
|
else
|
|
|
|
object.filter_quotes(@parent_post)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|