mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 10:06:53 +08:00
26 lines
543 B
Ruby
26 lines
543 B
Ruby
module ClientApi
|
|
module Teams
|
|
class CreateService < BaseService
|
|
attr_accessor :team
|
|
|
|
def execute
|
|
@team = Team.new(@params)
|
|
@team.created_by = @current_user
|
|
|
|
if @team.save
|
|
# Okay, team is created, now
|
|
# add the current user as admin
|
|
UserTeam.create(
|
|
user: @current_user,
|
|
team: @team,
|
|
role: 2
|
|
)
|
|
|
|
success
|
|
else
|
|
error(@team.errors.full_messages.uniq.join('. '))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|