discourse/app/serializers/admin_user_serializer.rb

66 lines
1.4 KiB
Ruby
Raw Normal View History

2013-02-06 03:16:51 +08:00
class AdminUserSerializer < BasicUserSerializer
2013-02-07 23:45:24 +08:00
attributes :email,
:active,
:admin,
2013-04-05 04:14:55 +08:00
:moderator,
2013-02-07 23:45:24 +08:00
:last_seen_age,
2013-02-06 03:16:51 +08:00
:days_visited,
:last_emailed_age,
2013-02-07 23:45:24 +08:00
:created_at_age,
2013-02-06 03:16:51 +08:00
:username_lower,
:trust_level,
:flag_level,
2013-02-07 23:45:24 +08:00
:username,
2013-02-06 03:16:51 +08:00
:avatar_template,
:topics_entered,
:posts_read_count,
:time_read,
:can_approve,
:approved,
:banned_at,
:banned_till,
:is_banned,
:ip_address
def is_banned
object.is_banned?
end
def can_impersonate
scope.can_impersonate?(object)
end
def last_emailed_age
return nil if object.last_emailed_at.blank?
AgeWords.age_words(Time.now - object.last_emailed_at)
end
def last_seen_age
return nil if object.last_seen_at.blank?
AgeWords.age_words(Time.now - object.last_seen_at)
end
def time_read
return nil if object.time_read.blank?
AgeWords.age_words(object.time_read)
end
def created_at_age
AgeWords.age_words(Time.now - object.created_at)
end
def can_approve
scope.can_approve?(object)
end
def include_can_approve?
SiteSetting.must_approve_users
end
def include_approved?
SiteSetting.must_approve_users
end
end