discourse/app/serializers/invited_user_serializer.rb

53 lines
1.0 KiB
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
class InvitedUserSerializer < BasicUserSerializer
2013-02-07 10:45:24 -05:00
attributes :topics_entered,
:posts_read_count,
:last_seen_at,
:time_read,
2013-02-05 14:16:51 -05:00
:days_visited,
:days_since_created
attr_accessor :invited_by
2013-02-05 14:16:51 -05:00
def time_read
AgeWords.age_words(object.user_stat.time_read)
end
def include_time_read?
scope.can_see_invite_details?(invited_by)
end
def days_visited
object.user_stat.days_visited
end
def include_days_visited?
scope.can_see_invite_details?(invited_by)
end
def topics_entered
object.user_stat.topics_entered
end
def include_topics_entered?
scope.can_see_invite_details?(invited_by)
end
def posts_read_count
object.user_stat.posts_read_count
2013-02-05 14:16:51 -05:00
end
def include_posts_read_count?
scope.can_see_invite_details?(invited_by)
end
2013-02-05 14:16:51 -05:00
def days_since_created
((Time.now - object.created_at) / 60 / 60 / 24).ceil
end
def include_days_since_created
scope.can_see_invite_details?(invited_by)
end
2013-02-05 14:16:51 -05:00
end