Changes: * Change the `expires_at` field to `duration`. * Make moderators choose from a fixed set of standard ban lengths, instead of allowing arbitrary ban lengths. * List `duration` in seconds in the /bans.json API. * Dump bans to BigQuery. Note that some old bans have a negative duration. This is because their expiration date was before their creation date, which is because in 2013 bans were migrated to Danbooru 2 and the original ban creation dates were lost.
44 lines
927 B
Ruby
44 lines
927 B
Ruby
class BansController < ApplicationController
|
|
respond_to :html, :xml, :json, :js
|
|
|
|
def new
|
|
@ban = authorize Ban.new(permitted_attributes(Ban))
|
|
respond_with(@ban)
|
|
end
|
|
|
|
def edit
|
|
@ban = authorize Ban.find(params[:id])
|
|
respond_with(@ban)
|
|
end
|
|
|
|
def index
|
|
@bans = authorize Ban.paginated_search(params, count_pages: true)
|
|
@bans = @bans.includes(:user, :banner) if request.format.html?
|
|
|
|
respond_with(@bans)
|
|
end
|
|
|
|
def show
|
|
@ban = authorize Ban.find(params[:id])
|
|
respond_with(@ban)
|
|
end
|
|
|
|
def create
|
|
@ban = authorize Ban.new(banner: CurrentUser.user, **permitted_attributes(Ban))
|
|
@ban.save
|
|
respond_with(@ban, location: bans_path)
|
|
end
|
|
|
|
def update
|
|
@ban = authorize Ban.find(params[:id])
|
|
@ban.update(permitted_attributes(@ban))
|
|
respond_with(@ban)
|
|
end
|
|
|
|
def destroy
|
|
@ban = authorize Ban.find(params[:id])
|
|
@ban.destroy
|
|
respond_with(@ban)
|
|
end
|
|
end
|