Commit 9de23248d8f3d6464d329b979ccfe98c23eb4aa3

Authored by Dmitriy Zaporozhets
1 parent 1dd66061

You should not be able to remove a Group owner

app/controllers/users_groups_controller.rb
... ... @@ -18,7 +18,7 @@ class UsersGroupsController < ApplicationController
18 18  
19 19 def destroy
20 20 @users_group = @group.users_groups.find(params[:id])
21   - @users_group.destroy
  21 + @users_group.destroy unless @users_group.user == @group.owner
22 22  
23 23 respond_to do |format|
24 24 format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' }
... ...
app/views/users_groups/_users_group.html.haml
... ... @@ -13,6 +13,6 @@
13 13 - else
14 14 = member.human_access
15 15  
16   - - if show_controls && user != current_user
  16 + - if show_controls && user != current_user && user != @group.owner
17 17 = 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
18 18 %i.icon-minus.icon-white
... ...
lib/tasks/migrate/migrate_groups.rake 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +desc "GITLAB | Migrate Gropus to match v6.0"
  2 +task migrate_groups: :environment do
  3 + puts "This will add group owners to group membership"
  4 + ask_to_continue
  5 +
  6 + Group.find_each(batch_size: 20) do |group|
  7 + begin
  8 + group.send :add_owner
  9 + print '.'
  10 + rescue => ex
  11 + puts ex.message
  12 + print 'F'
  13 + end
  14 + end
  15 +end
  16 +
... ...