Code duplication removed from controllers
This commit is contained in:
parent
39e7a0eafe
commit
98044f0f14
|
@ -68,9 +68,7 @@ class Admin::GroupsController < AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_teams_update
|
def project_teams_update
|
||||||
@group.projects.each do |project|
|
@group.add_users_to_project_teams(params[:user_ids], params[:project_access])
|
||||||
project.add_users_ids_to_team(params[:user_ids], params[:project_access])
|
|
||||||
end
|
|
||||||
redirect_to [:admin, @group], notice: 'Users was successfully added.'
|
redirect_to [:admin, @group], notice: 'Users was successfully added.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,7 @@ class GroupsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def team_members
|
def team_members
|
||||||
@group.projects.each do |project|
|
@group.add_users_to_project_teams(params[:user_ids], params[:project_access])
|
||||||
project.add_users_ids_to_team(params[:user_ids], params[:project_access])
|
|
||||||
end
|
|
||||||
redirect_to people_group_path(@group), notice: 'Users was successfully added.'
|
redirect_to people_group_path(@group), notice: 'Users was successfully added.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,12 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
class Group < Namespace
|
class Group < Namespace
|
||||||
|
def add_users_to_project_teams(user_ids, project_access)
|
||||||
|
projects.each do |project|
|
||||||
|
project.add_users_ids_to_team(user_ids, project_access)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def users
|
def users
|
||||||
users = User.joins(:users_projects).where(users_projects: {project_id: project_ids})
|
users = User.joins(:users_projects).where(users_projects: {project_id: project_ids})
|
||||||
users = users << owner
|
users = users << owner
|
||||||
|
|
Loading…
Reference in a new issue