summaryrefslogtreecommitdiff
path: root/app/controllers/admin
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-26 15:57:02 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-26 15:57:02 +0300
commit1dd80d22a58d6407951e89eedcdbf21d340f9261 (patch)
tree65a987900b5d592f11adebcf4be1ce3d7af96791 /app/controllers/admin
parent21f7c99c25615961f6eed870b38ba8fba558b879 (diff)
downloadgitlab-ce-1dd80d22a58d6407951e89eedcdbf21d340f9261.tar.gz
Prevent confusion in naming user variable at admin area
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/users_controller.rb52
1 files changed, 26 insertions, 26 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index fefd2594880..62b9fe08091 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -1,27 +1,27 @@
class Admin::UsersController < Admin::ApplicationController
- before_filter :admin_user, only: [:show, :edit, :update, :destroy]
+ before_filter :user, only: [:show, :edit, :update, :destroy]
def index
- @admin_users = User.scoped
- @admin_users = @admin_users.filter(params[:filter])
- @admin_users = @admin_users.search(params[:name]) if params[:name].present?
- @admin_users = @admin_users.alphabetically.page(params[:page])
+ @users = User.scoped
+ @users = @users.filter(params[:filter])
+ @users = @users.search(params[:name]) if params[:name].present?
+ @users = @users.alphabetically.page(params[:page])
end
def show
- @projects = admin_user.authorized_projects
+ @projects = user.authorized_projects
end
def new
- @admin_user = User.new.with_defaults
+ @user = User.new.with_defaults
end
def edit
- admin_user
+ user
end
def block
- if admin_user.block
+ if user.block
redirect_to :back, alert: "Successfully blocked"
else
redirect_to :back, alert: "Error occured. User was not blocked"
@@ -29,7 +29,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def unblock
- if admin_user.activate
+ if user.activate
redirect_to :back, alert: "Successfully unblocked"
else
redirect_to :back, alert: "Error occured. User was not unblocked"
@@ -44,17 +44,17 @@ class Admin::UsersController < Admin::ApplicationController
password_expires_at: Time.now
}
- @admin_user = User.new(params[:user].merge(opts), as: :admin)
- @admin_user.admin = (admin && admin.to_i > 0)
- @admin_user.created_by_id = current_user.id
+ @user = User.new(params[:user].merge(opts), as: :admin)
+ @user.admin = (admin && admin.to_i > 0)
+ @user.created_by_id = current_user.id
respond_to do |format|
- if @admin_user.save
- format.html { redirect_to [:admin, @admin_user], notice: 'User was successfully created.' }
- format.json { render json: @admin_user, status: :created, location: @admin_user }
+ if @user.save
+ format.html { redirect_to [:admin, @user], notice: 'User was successfully created.' }
+ format.json { render json: @user, status: :created, location: @user }
else
format.html { render "new" }
- format.json { render json: @admin_user.errors, status: :unprocessable_entity }
+ format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
@@ -67,26 +67,26 @@ class Admin::UsersController < Admin::ApplicationController
params[:user].delete(:password_confirmation)
end
- admin_user.admin = (admin && admin.to_i > 0)
+ user.admin = (admin && admin.to_i > 0)
respond_to do |format|
- if admin_user.update_attributes(params[:user], as: :admin)
- format.html { redirect_to [:admin, admin_user], notice: 'User was successfully updated.' }
+ if user.update_attributes(params[:user], as: :admin)
+ format.html { redirect_to [:admin, user], notice: 'User was successfully updated.' }
format.json { head :ok }
else
# restore username to keep form action url.
- admin_user.username = params[:id]
+ user.username = params[:id]
format.html { render "edit" }
- format.json { render json: admin_user.errors, status: :unprocessable_entity }
+ format.json { render json: user.errors, status: :unprocessable_entity }
end
end
end
def destroy
- if admin_user.personal_projects.count > 0
+ if user.personal_projects.count > 0
redirect_to admin_users_path, alert: "User is a project owner and can't be removed." and return
end
- admin_user.destroy
+ user.destroy
respond_to do |format|
format.html { redirect_to admin_users_path }
@@ -96,7 +96,7 @@ class Admin::UsersController < Admin::ApplicationController
protected
- def admin_user
- @admin_user ||= User.find_by_username!(params[:id])
+ def user
+ @user ||= User.find_by_username!(params[:id])
end
end