2016-03-16 22:44:33 +00:00
|
|
|
module Groups
|
|
|
|
class CreateService < Groups::BaseService
|
2016-03-17 22:42:46 +00:00
|
|
|
def initialize(user, params = {})
|
|
|
|
@current_user, @params = user, params.dup
|
2016-03-16 22:44:33 +00:00
|
|
|
end
|
|
|
|
|
2016-03-17 22:42:46 +00:00
|
|
|
def execute
|
2016-03-18 12:28:16 +00:00
|
|
|
@group = Group.new(params)
|
|
|
|
|
|
|
|
return @group unless visibility_allowed_for_user?
|
|
|
|
|
2016-03-17 22:42:46 +00:00
|
|
|
@group.name = @group.path.dup unless @group.name
|
|
|
|
@group.save
|
2016-03-18 12:28:16 +00:00
|
|
|
@group.add_owner(current_user)
|
2016-03-17 22:42:46 +00:00
|
|
|
@group
|
2016-03-16 22:44:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|