Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-10-06 17:30:34 +0300
committerPhil Hughes <me@iamphill.com>2016-10-06 17:30:34 +0300
commit996e802415aa1edadb96b1f7efa924581fb047ed (patch)
tree316dd7319d2cc723b5c311f099065e9b4fdb11d6 /app/controllers/projects/group_links_controller.rb
parenta0eaff14124b829ccc02df951bd7cb7d3abb7708 (diff)
parentdcfda304aa8c06f427cb5672ceb4e070047436be (diff)
Merge branch 'master' into members-ui
Diffstat (limited to 'app/controllers/projects/group_links_controller.rb')
-rw-r--r--app/controllers/projects/group_links_controller.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/app/controllers/projects/group_links_controller.rb b/app/controllers/projects/group_links_controller.rb
index 2994d8c9666..ae060abee5c 100644
--- a/app/controllers/projects/group_links_controller.rb
+++ b/app/controllers/projects/group_links_controller.rb
@@ -5,17 +5,25 @@ class Projects::GroupLinksController < Projects::ApplicationController
def index
@group_links = project.project_group_links.all
+
+ @skip_groups = @group_links.pluck(:group_id)
+ @skip_groups << project.group.try(:id)
end
def create
- group = Group.find(params[:link_group_id])
- return render_404 unless can?(current_user, :read_group, group)
-
- project.project_group_links.create(
- group: group,
- group_access: params[:link_group_access],
- expires_at: params[:expires_at]
- )
+ group = Group.find(params[:link_group_id]) if params[:link_group_id].present?
+
+ if group
+ return render_404 unless can?(current_user, :read_group, group)
+
+ project.project_group_links.create(
+ group: group,
+ group_access: params[:link_group_access],
+ expires_at: params[:expires_at]
+ )
+ else
+ flash[:alert] = 'Please select a group.'
+ end
redirect_to namespace_project_group_links_path(project.namespace, project)
end