Files
danbooru/app/controllers/user_name_change_requests_controller.rb
evazion 3b63f94968 user name changes: remove unused reason, status fields.
Remove all infrastructure around approving or rejecting user name
changes. Name changes haven't been moderated for several years.

* Remove status, approver_id, change_reason, and rejection_reason fields.
* Remove approve and reject controller actions.
2019-09-25 21:43:01 -05:00

39 lines
1.2 KiB
Ruby

class UserNameChangeRequestsController < ApplicationController
before_action :member_only, :only => [:index, :show]
before_action :gold_only, :only => [:new, :create]
respond_to :html, :json, :xml
def new
@change_request = UserNameChangeRequest.new(change_request_params)
respond_with(@change_request)
end
def create
@change_request = UserNameChangeRequest.create_with(user: CurrentUser.user, original_name: CurrentUser.name).create(change_request_params)
flash[:notice] = "Your name has been changed"
respond_with(@change_request, location: profile_path)
end
def show
@change_request = UserNameChangeRequest.find(params[:id])
check_privileges!(@change_request)
respond_with(@change_request)
end
def index
@change_requests = UserNameChangeRequest.visible.order("id desc").paginate(params[:page], :limit => params[:limit])
respond_with(@change_requests)
end
private
def check_privileges!(change_request)
return if CurrentUser.is_admin?
raise User::PrivilegeError if change_request.user_id != CurrentUser.user.id
end
def change_request_params
params.fetch(:user_name_change_request, {}).permit(%i[desired_name])
end
end