listbooru: raise exception if not configured.

This commit is contained in:
evazion
2017-04-05 00:34:24 -05:00
parent 086b520dcc
commit 08867fa84d
2 changed files with 7 additions and 27 deletions

View File

@@ -1,25 +0,0 @@
module SavedSearches
module CheckAvailability
extend ActiveSupport::Concern
included do
before_filter :check_availability
end
def check_availability
if !SavedSearch.enabled?
respond_to do |format|
format.html do
flash[:notice] = "Listbooru service is not configured. Saved searches are not available."
redirect_to :back
end
format.json do
render json: {success: false, reason: "Listbooru service is not configured"}.to_json, status: 501
end
end
return false
end
end
end
end

View File

@@ -1,7 +1,6 @@
class SavedSearchesController < ApplicationController
include SavedSearches::CheckAvailability
before_filter :member_only
before_filter :check_availability
respond_to :html, :xml, :json, :js
def index
@@ -56,4 +55,10 @@ private
def saved_searches
CurrentUser.user.saved_searches
end
def check_availability
if !SavedSearch.enabled?
raise NotImplementedError.new("Listbooru service is not configured. Saved searches are not available.")
end
end
end