2013-02-05 13:16:51 -06:00
|
|
|
class AdminUserSerializer < BasicUserSerializer
|
|
|
|
|
2013-02-07 09:45:24 -06:00
|
|
|
attributes :email,
|
|
|
|
:active,
|
|
|
|
:admin,
|
2013-04-04 15:14:55 -05:00
|
|
|
:moderator,
|
2013-02-07 09:45:24 -06:00
|
|
|
:last_seen_age,
|
2013-02-05 13:16:51 -06:00
|
|
|
:last_emailed_age,
|
2013-02-07 09:45:24 -06:00
|
|
|
:created_at_age,
|
2013-02-05 13:16:51 -06:00
|
|
|
:username_lower,
|
|
|
|
:trust_level,
|
|
|
|
:flag_level,
|
2013-02-07 09:45:24 -06:00
|
|
|
:username,
|
2013-06-25 17:39:20 -05:00
|
|
|
:title,
|
2013-02-05 13:16:51 -06:00
|
|
|
:avatar_template,
|
|
|
|
:can_approve,
|
|
|
|
:approved,
|
|
|
|
:banned_at,
|
|
|
|
:banned_till,
|
|
|
|
:is_banned,
|
2013-05-07 20:58:34 -05:00
|
|
|
:ip_address,
|
|
|
|
:can_send_activation_email,
|
|
|
|
:can_activate,
|
2013-05-31 10:41:40 -05:00
|
|
|
:can_deactivate,
|
2013-10-03 22:28:49 -05:00
|
|
|
:blocked,
|
|
|
|
:time_read
|
|
|
|
|
|
|
|
[:days_visited,:posts_read_count,:topics_entered].each do |sym|
|
|
|
|
attributes sym
|
|
|
|
define_method sym do
|
|
|
|
object.user_stat.send(sym)
|
|
|
|
end
|
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
|
|
|
|
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
|
2013-10-03 22:28:49 -05:00
|
|
|
return nil if object.user_stat.time_read.blank?
|
|
|
|
AgeWords.age_words(object.user_stat.time_read)
|
2013-02-05 13:16:51 -06:00
|
|
|
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
|
|
|
|
|
2013-05-07 20:58:34 -05:00
|
|
|
def can_send_activation_email
|
|
|
|
scope.can_send_activation_email?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_activate
|
|
|
|
scope.can_activate?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_deactivate
|
|
|
|
scope.can_deactivate?(object)
|
|
|
|
end
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|