Commit afdfbd1e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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

parent 79f0858a
...@@ -83,9 +83,14 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -83,9 +83,14 @@ class Admin::UsersController < Admin::ApplicationController
end end
def destroy def destroy
if user.personal_projects.count > 0 # 1. Move all user groups to admin
redirect_to admin_users_path, alert: "User is a project owner and can't be removed." and return user.own_groups.each do |group|
group.owner_id = User.admins.first
group.save
end end
# 2. Remove user with all authored contenst
# including personal projects
user.destroy user.destroy
respond_to do |format| respond_to do |format|
......
...@@ -7,15 +7,14 @@ ...@@ -7,15 +7,14 @@
%span.cred (Admin) %span.cred (Admin)
.pull-right .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 %i.icon-edit
Edit Edit
- unless @user == current_user - unless @user == current_user
- if @user.blocked? - 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 - 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 'Block', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn grouped 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"
%hr %hr
.row .row
...@@ -63,6 +62,17 @@ ...@@ -63,6 +62,17 @@
%strong %strong
= link_to @user.created_by.name, [:admin, @user.created_by] = 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? - if @user.users_groups.present?
.ui-box .ui-box
.title Groups: .title Groups:
...@@ -74,7 +84,6 @@ ...@@ -74,7 +84,6 @@
.pull-right .pull-right
%span.light= user_group.human_access %span.light= user_group.human_access
.span6
.ui-box .ui-box
.title Projects (#{@projects.count}) .title Projects (#{@projects.count})
%ul.well-list %ul.well-list
...@@ -96,3 +105,5 @@ ...@@ -96,3 +105,5 @@
%span.light= tm.human_access %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 = 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 %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