Files
danbooru/app/controllers/ip_addresses_controller.rb
evazion f23df47c09 ip addresses: add ip address show page.
* Add IP address show page at /ip_addresses/1.2.3.4.
* Add "Details", "Ban IP", "Ban User" options to the /ip_addresses listing.
2020-03-23 01:48:59 -05:00

24 lines
716 B
Ruby

class IpAddressesController < ApplicationController
respond_to :html, :xml, :json
def index
@ip_addresses = authorize IpAddress.visible(CurrentUser.user).paginated_search(params)
if search_params[:group_by] == "ip_addr"
@ip_addresses = @ip_addresses.group_by_ip_addr(search_params[:ipv4_masklen], search_params[:ipv6_masklen])
elsif search_params[:group_by] == "user"
@ip_addresses = @ip_addresses.group_by_user.includes(:user)
else
@ip_addresses = @ip_addresses.includes(:user, :model)
end
respond_with(@ip_addresses)
end
def show
@ip_address = IpAddress.new(ip_addr: params[:id])
@ip_info = @ip_address.lookup.info
respond_with(@ip_info)
end
end