2016-11-25 02:26:49 -05:00
|
|
|
class GroupShowSerializer < BasicGroupSerializer
|
2016-11-29 03:25:02 -05:00
|
|
|
attributes :is_group_user, :is_group_owner
|
2016-11-25 02:26:49 -05:00
|
|
|
|
|
|
|
def include_is_group_user?
|
|
|
|
scope.authenticated?
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_group_user
|
2016-11-29 03:25:02 -05:00
|
|
|
!!fetch_group_user
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_is_group_owner?
|
|
|
|
scope.authenticated?
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_group_owner
|
|
|
|
scope.is_admin? || fetch_group_user&.owner
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_group_user
|
|
|
|
@group_user ||= object.group_users.find_by(user: scope.user)
|
2016-11-25 02:26:49 -05:00
|
|
|
end
|
|
|
|
end
|