summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-22 11:02:31 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-22 11:02:31 +0300
commit9de23248d8f3d6464d329b979ccfe98c23eb4aa3 (patch)
treedfdd4a66faf877f1f874f066272818936ce6e819
parent1dd6606161bea762cefe14c7a39f79a8c0b43dd7 (diff)
downloadgitlab-ce-9de23248d8f3d6464d329b979ccfe98c23eb4aa3.tar.gz
You should not be able to remove a Group owner
-rw-r--r--app/controllers/users_groups_controller.rb2
-rw-r--r--app/views/users_groups/_users_group.html.haml2
-rw-r--r--lib/tasks/migrate/migrate_groups.rake16
3 files changed, 18 insertions, 2 deletions
diff --git a/app/controllers/users_groups_controller.rb b/app/controllers/users_groups_controller.rb
index 9181f1683ae..c30034d7d0e 100644
--- a/app/controllers/users_groups_controller.rb
+++ b/app/controllers/users_groups_controller.rb
@@ -18,7 +18,7 @@ class UsersGroupsController < ApplicationController
def destroy
@users_group = @group.users_groups.find(params[:id])
- @users_group.destroy
+ @users_group.destroy unless @users_group.user == @group.owner
respond_to do |format|
format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' }
diff --git a/app/views/users_groups/_users_group.html.haml b/app/views/users_groups/_users_group.html.haml
index c6dca5f3425..3a1e32dd79d 100644
--- a/app/views/users_groups/_users_group.html.haml
+++ b/app/views/users_groups/_users_group.html.haml
@@ -13,6 +13,6 @@
- else
= member.human_access
- - if show_controls && user != current_user
+ - if show_controls && user != current_user && user != @group.owner
= link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
%i.icon-minus.icon-white
diff --git a/lib/tasks/migrate/migrate_groups.rake b/lib/tasks/migrate/migrate_groups.rake
new file mode 100644
index 00000000000..153172dc90a
--- /dev/null
+++ b/lib/tasks/migrate/migrate_groups.rake
@@ -0,0 +1,16 @@
+desc "GITLAB | Migrate Gropus to match v6.0"
+task migrate_groups: :environment do
+ puts "This will add group owners to group membership"
+ ask_to_continue
+
+ Group.find_each(batch_size: 20) do |group|
+ begin
+ group.send :add_owner
+ print '.'
+ rescue => ex
+ puts ex.message
+ print 'F'
+ end
+ end
+end
+