mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-30 11:24:21 +01:00
22 lines
522 B
Ruby
22 lines
522 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Provides methods for Groups
|
|
class GroupService
|
|
def self.list(operator, filters = {})
|
|
groups = if operator&.admin?
|
|
Group.where(nil)
|
|
else
|
|
Group.where.not(slug: 'admins')
|
|
end
|
|
|
|
if filters[:disabled].present?
|
|
state = filters[:disabled] == 'false' ? [nil, false] : true
|
|
groups = groups.where(disabled: state)
|
|
end
|
|
|
|
groups = groups.where.not(slug: 'admins') if filters[:admins] == 'false'
|
|
|
|
groups
|
|
end
|
|
end
|