blob: 394f0ee10ec21d4000197e04bbaab34e8b081eba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# frozen_string_literal: true
module BulkImports
module Groups
module Loaders
class GroupLoader
def initialize(options = {})
@options = options
end
def load(context, data)
return unless user_can_create_group?(context.current_user, data)
::Groups::CreateService.new(context.current_user, data).execute
end
private
def user_can_create_group?(current_user, data)
if data['parent_id']
parent = Namespace.find_by_id(data['parent_id'])
Ability.allowed?(current_user, :create_subgroup, parent)
else
Ability.allowed?(current_user, :create_group)
end
end
end
end
end
end
|