2013-06-28 12:55:34 -05: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,
|
2014-05-22 02:37:02 -05:00
|
|
|
:uploaded_avatar_id,
|
2013-06-28 12:55:34 -05:00
|
|
|
:created_at,
|
2014-06-20 16:06:44 -05:00
|
|
|
:cooked,
|
|
|
|
:cooked_hidden
|
2013-06-28 12:55:34 -05:00
|
|
|
|
|
|
|
def name
|
2013-09-03 16:19:29 -05:00
|
|
|
object.user.try(:name)
|
2013-06-28 12:55:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def username
|
2013-09-03 16:19:29 -05:00
|
|
|
object.user.try(:username)
|
2013-06-28 12:55:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def avatar_template
|
2013-09-03 16:19:29 -05:00
|
|
|
object.user.try(:avatar_template)
|
2013-06-28 12:55:34 -05:00
|
|
|
end
|
|
|
|
|
2014-05-22 02:37:02 -05:00
|
|
|
def uploaded_avatar_id
|
|
|
|
object.user.try(:uploaded_avatar_id)
|
|
|
|
end
|
|
|
|
|
2014-06-20 16:06:44 -05:00
|
|
|
def cooked_hidden
|
|
|
|
object.hidden && !scope.is_staff?
|
|
|
|
end
|
|
|
|
def include_cooked_hidden?
|
|
|
|
cooked_hidden
|
|
|
|
end
|
|
|
|
|
2013-06-28 12:55:34 -05:00
|
|
|
def cooked
|
2014-06-20 16:06:44 -05:00
|
|
|
if cooked_hidden
|
2013-06-28 12:55:34 -05:00
|
|
|
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
|
|
|
|
|
2013-10-30 14:45:13 -05:00
|
|
|
def include_name?
|
|
|
|
SiteSetting.enable_names?
|
|
|
|
end
|
|
|
|
|
2013-06-28 12:55:34 -05:00
|
|
|
end
|