lib/mno_enterprise/concerns/controllers/jpi/v1/teams_controller.rb in mno-enterprise-api-3.2.1 vs lib/mno_enterprise/concerns/controllers/jpi/v1/teams_controller.rb in mno-enterprise-api-3.3.0

- old
+ new

@@ -28,10 +28,12 @@ # POST /mnoe/jpi/v1/organizations/:organization_id/teams def create authorize! :manage_teams, parent_organization @team = parent_organization.teams.create(team_params) + MnoEnterprise::EventLogger.info('team_add', current_user.id, 'Team created', @team) if @team + render 'show' end # PUT /mnoe/jpi/v1/teams/:id def update @@ -43,10 +45,14 @@ # # Update permissions if params[:team] && params[:team][:app_instances] list = params[:team][:app_instances].select { |e| e != {} } @team.set_access_to(list) + + MnoEnterprise::EventLogger.info('team_apps_update', current_user.id, 'Team apps updated', @team, + {apps: list.map{|l| l['name']}}) + end render 'show' end @@ -62,12 +68,15 @@ # DELETE /mnoe/jpi/v1/teams/:id def destroy @team = MnoEnterprise::Team.find(params[:id]) authorize! :manage_teams, @team.organization + @team.destroy + MnoEnterprise::EventLogger.info('team_delete', current_user.id, 'Team deleted', @team) if @team + head :no_content end private @@ -78,10 +87,14 @@ authorize! :manage_teams, @team.organization if params[:team] && params[:team][:users] id_list = params[:team][:users].map { |h| h[:id] }.compact users = @team.organization.users.where('id.in' => id_list) + users.each { |u| @team.send(action, u) } + + MnoEnterprise::EventLogger.info('team_update', current_user.id, 'Team composition updated', @team, + {action: action.to_s, users: users.map(&:email)}) end render 'show' end