diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index bd6b44bdbbceacb03df7fec8f39cc42bbf441c1f..e8d9d9fb34431c18ac0de1ff796d4c0367c4f76d 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -133,7 +133,7 @@ class GroupsController < Groups::ApplicationController end def group_params - params.require(:group).permit(:name, :description, :path, :avatar, :public) + params.require(:group).permit(:name, :description, :path, :avatar, :public, :share_with_group_lock) end def load_events diff --git a/app/models/project.rb b/app/models/project.rb index 56865459724fecc39b0ddbd1c5573a69acc78e34..40f8c4c83da5bff5d858a70a56b080c3530dc91c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -881,8 +881,7 @@ class Project < ActiveRecord::Base end def allowed_to_share_with_group? - # TODO: replace with logic - true + !namespace.share_with_group_lock end def ci_commit(sha) diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index 3430f56a9c98890681fba9d0974beab6ebe7d471..83936d39b16fd3cc11b24d621f189b5bce6f0757 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -23,6 +23,15 @@ %hr = link_to 'Remove avatar', group_avatar_path(@group.to_param), data: { confirm: "Group avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-sm remove-avatar" + .form-group + %hr + = f.label :share_with_group_lock, class: 'control-label' do + Share with group lock + .col-sm-10 + .checkbox + = f.check_box :share_with_group_lock + %span.descr Prevent sharing a project with another group within this group + .form-actions = f.submit 'Save group', class: "btn btn-save" diff --git a/db/migrate/20150930110012_add_group_share_lock.rb b/db/migrate/20150930110012_add_group_share_lock.rb new file mode 100644 index 0000000000000000000000000000000000000000..78d1a4538f250870e944f4a6fc559687dc917428 --- /dev/null +++ b/db/migrate/20150930110012_add_group_share_lock.rb @@ -0,0 +1,5 @@ +class AddGroupShareLock < ActiveRecord::Migration + def change + add_column :namespaces, :share_with_group_lock, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 89e8c9e67b0685994aff9fc95fd0d84a63788221..20dbb4f5a3eb7f6b4417e4a5fbf5a7462e0e8a5f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -568,14 +568,15 @@ ActiveRecord::Schema.define(version: 20160309140734) do add_index "milestones", ["title"], name: "index_milestones_on_title", using: :btree create_table "namespaces", force: :cascade do |t| - t.string "name", null: false - t.string "path", null: false + t.string "name", null: false + t.string "path", null: false t.integer "owner_id" t.datetime "created_at" t.datetime "updated_at" t.string "type" - t.string "description", default: "", null: false + t.string "description", default: "", null: false t.string "avatar" + t.boolean "share_with_group_lock", default: false end add_index "namespaces", ["created_at", "id"], name: "index_namespaces_on_created_at_and_id", using: :btree