Commit afdfbd1e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Add description to user removal block. Transfer owned groups to admin before remove

parent 79f0858a
......@@ -83,9 +83,14 @@ def update
end
def destroy
if user.personal_projects.count > 0
redirect_to admin_users_path, alert: "User is a project owner and can't be removed." and return
# 1. Move all user groups to admin
user.own_groups.each do |group|
group.owner_id = User.admins.first
group.save
end
# 2. Remove user with all authored contenst
# including personal projects
user.destroy
respond_to do |format|
......
......@@ -7,15 +7,14 @@
%span.cred (Admin)
.pull-right
= link_to edit_admin_user_path(@user), class: "btn grouped btn-small" do
= link_to edit_admin_user_path(@user), class: "btn grouped" do
%i.icon-edit
Edit
- unless @user == current_user
- if @user.blocked?
= link_to 'Unblock', unblock_admin_user_path(@user), method: :put, class: "btn grouped btn-small success"
= link_to 'Unblock', unblock_admin_user_path(@user), method: :put, class: "btn grouped success"
- else
= link_to 'Block', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn grouped btn-small btn-remove"
= link_to 'Destroy', [:admin, @user], confirm: "USER #{@user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn grouped btn-small btn-remove"
= link_to 'Block', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn grouped btn-remove"
%hr
.row
......@@ -63,6 +62,17 @@
%strong
= link_to @user.created_by.name, [:admin, @user.created_by]
.alert.alert-error
%h4 Remove user
%br
%p Deleting a user has the following effects:
%ul
%li All user content like authored issues, snippets, comments will be removed
%li User personal projects will be removed and cannot be restored
%li Owned groups will be transfered to first admin
= link_to 'Remove user', [:admin, @user], confirm: "USER #{@user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-remove"
.span6
- if @user.users_groups.present?
.ui-box
.title Groups:
......@@ -74,7 +84,6 @@
.pull-right
%span.light= user_group.human_access
.span6
.ui-box
.title Projects (#{@projects.count})
%ul.well-list
......@@ -96,3 +105,5 @@
%span.light= tm.human_access
= link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @user), method: :delete, class: "btn btn-small btn-remove" do
%i.icon-remove
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment