Files
danbooru/app/controllers/ip_bans_controller.rb
evazion b2ee1f0766 ip bans: add hit counter, deleted flag, new ban type.
* Make IP bans soft deletable.
* Add a hit counter to track how many times an IP ban has blocked someone.
* Add a last hit timestamp to track when the IP ban last blocked someone.
* Add a new type of IP ban, the signup ban. Signup bans restrict new
  signups from editing anything until they've verified their email
  address.
2020-04-06 14:13:22 -05:00

29 lines
710 B
Ruby

class IpBansController < ApplicationController
respond_to :html, :xml, :json, :js
def new
@ip_ban = authorize IpBan.new(permitted_attributes(IpBan))
respond_with(@ip_ban)
end
def create
@ip_ban = authorize IpBan.new(creator: CurrentUser.user, **permitted_attributes(IpBan))
@ip_ban.save
respond_with(@ip_ban, :location => ip_bans_path)
end
def index
@ip_bans = authorize IpBan.paginated_search(params, count_pages: true)
@ip_bans = @ip_bans.includes(:creator) if request.format.html?
respond_with(@ip_bans)
end
def update
@ip_ban = authorize IpBan.find(params[:id])
@ip_ban.update(permitted_attributes(@ip_ban))
respond_with(@ip_ban)
end
end