hide saved search functionality if not enabled

This commit is contained in:
Albert Yi
2016-12-21 11:54:43 -08:00
parent ee4ebce4d7
commit 62956be384
14 changed files with 198 additions and 104 deletions

View File

@@ -1,5 +1,6 @@
class SavedSearchCategoryChangesController < ApplicationController
before_filter :member_only
before_filter :check_availabililty
respond_to :html
def new
@@ -11,4 +12,22 @@ class SavedSearchCategoryChangesController < ApplicationController
flash[:notice] = "Saved searches will be renamed"
redirect_to saved_searches_path
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

View File

@@ -1,5 +1,6 @@
class SavedSearchesController < ApplicationController
before_filter :member_only
before_fitler :check_availability
respond_to :html, :xml, :json, :js
def index
@@ -47,6 +48,22 @@ class SavedSearchesController < ApplicationController
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
CurrentUser.user.saved_searches
end