Fix #2795: "check_availability" bug with saved searches.
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
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
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
class SavedSearchCategoryChangesController < ApplicationController
|
class SavedSearchCategoryChangesController < ApplicationController
|
||||||
|
include SavedSearches::CheckAvailability
|
||||||
|
|
||||||
before_filter :member_only
|
before_filter :member_only
|
||||||
before_filter :check_availabililty
|
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@@ -12,22 +13,4 @@ class SavedSearchCategoryChangesController < ApplicationController
|
|||||||
flash[:notice] = "Saved searches will be renamed"
|
flash[:notice] = "Saved searches will be renamed"
|
||||||
redirect_to saved_searches_path
|
redirect_to saved_searches_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def check_availabililty
|
|
||||||
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
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class SavedSearchesController < ApplicationController
|
class SavedSearchesController < ApplicationController
|
||||||
|
include SavedSearches::CheckAvailability
|
||||||
|
|
||||||
before_filter :member_only
|
before_filter :member_only
|
||||||
before_filter :check_availability
|
|
||||||
respond_to :html, :xml, :json, :js
|
respond_to :html, :xml, :json, :js
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@@ -47,23 +48,6 @@ class SavedSearchesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_availabililty
|
|
||||||
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
|
|
||||||
|
|
||||||
def saved_searches
|
def saved_searches
|
||||||
CurrentUser.user.saved_searches
|
CurrentUser.user.saved_searches
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user