2013-05-09 17:37:34 +10:00
|
|
|
class BasicGroupSerializer < ApplicationSerializer
|
2015-01-23 18:25:43 +01:00
|
|
|
attributes :id,
|
|
|
|
:automatic,
|
|
|
|
:name,
|
|
|
|
:user_count,
|
|
|
|
:alias_level,
|
|
|
|
:visible,
|
|
|
|
:automatic_membership_email_domains,
|
2015-04-10 12:17:28 +10:00
|
|
|
:automatic_membership_retroactive,
|
|
|
|
:primary_group,
|
2015-09-01 16:52:05 -04:00
|
|
|
:title,
|
2015-12-07 12:39:28 +01:00
|
|
|
:grant_trust_level,
|
2015-12-14 23:17:09 +01:00
|
|
|
:incoming_email,
|
2015-12-17 18:06:04 +11:00
|
|
|
:notification_level,
|
2016-03-02 23:48:17 +05:30
|
|
|
:has_messages,
|
|
|
|
:mentionable
|
2015-12-07 12:39:28 +01:00
|
|
|
|
|
|
|
def include_incoming_email?
|
|
|
|
scope.is_staff?
|
|
|
|
end
|
2015-12-14 23:17:09 +01:00
|
|
|
|
|
|
|
def notification_level
|
|
|
|
# TODO: fix this N+1
|
|
|
|
GroupUser.where(group_id: object.id, user_id: scope.user.id).first.try(:notification_level)
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_notification_level?
|
|
|
|
scope.authenticated?
|
|
|
|
end
|
|
|
|
|
2016-03-02 23:48:17 +05:30
|
|
|
def mentionable
|
|
|
|
object.mentionable?(scope.user, object.id)
|
|
|
|
end
|
|
|
|
|
2013-05-08 15:20:38 +10:00
|
|
|
end
|