Merge branch 'r-1902001-01' into foodcourt
This commit is contained in:
@@ -2,6 +2,8 @@ class ActionController::Base
|
||||
before_action :lookup_domain if Rails.env.production?
|
||||
before_action :set_locale
|
||||
|
||||
helper_method :current_license,
|
||||
|
||||
def not_found
|
||||
respond_to do |format|
|
||||
format.html { render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found }
|
||||
@@ -13,10 +15,9 @@ class ActionController::Base
|
||||
|
||||
def lookup_domain
|
||||
if ENV["SERVER_MODE"] == "cloud" && request.subdomains.last && request.subdomains.last != "www"
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], request.host) # request.subdomain.downcase
|
||||
if !@license.nil?
|
||||
logger.info "Location - " + @license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
if license = cache_license # request.subdomain.downcase
|
||||
logger.info "Location - " + license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(license))
|
||||
else
|
||||
# reconnect_default_db
|
||||
logger.info 'License is nil'
|
||||
@@ -24,47 +25,30 @@ class ActionController::Base
|
||||
end
|
||||
elsif ENV["SERVER_MODE"] == "application" || request.subdomains.last && request.subdomains.last != "www"
|
||||
# check for license file
|
||||
if check_license(request.host)
|
||||
current_license(ENV["SX_PROVISION_URL"], request.host)
|
||||
elsif ENV["SERVER_MODE"] == "application" || check_subdomain(request.host)
|
||||
if !current_license.exists?
|
||||
redirect_to activate_path
|
||||
else
|
||||
not_found
|
||||
elsif current_license.expired?
|
||||
redirect_to review_license_path
|
||||
end
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
Rails.logger.info "Run License"
|
||||
end
|
||||
def current_license
|
||||
@license ||= License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
def cache_license
|
||||
if (current_license.detail_with_local_cache == true)
|
||||
return current_license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def check_subdomain(lookup)
|
||||
license = License.new(ENV["SX_PROVISION_URL"], lookup)
|
||||
license.check_license_subdomain(lookup)
|
||||
end
|
||||
|
||||
def check_license(lookup)
|
||||
License.check_license_file(lookup)
|
||||
def check_subdomain
|
||||
current_license.check_license_subdomain
|
||||
end
|
||||
|
||||
def check_installation
|
||||
@@ -76,7 +60,6 @@ class ActionController::Base
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
@@ -114,27 +97,28 @@ class ActionController::API
|
||||
|
||||
def lookup_domain
|
||||
if ENV["SERVER_CODE"] == "cloud" && request.subdomains.last && request.subdomains.last != "www"
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], request.host) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
logger.info "Location - " + @license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
if license = cache_license # request.subdomain.downcase
|
||||
logger.info "Location - " + license.dbschema
|
||||
ActiveRecord::Base.establish_connection(website_connection(license))
|
||||
else
|
||||
# reconnect_default_db
|
||||
logger.info 'License is nil'
|
||||
not_found
|
||||
end
|
||||
elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www")
|
||||
not_found unless check_license(request.host)
|
||||
not_found unless current_license.exists? && !current_license.expired?
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
def current_license
|
||||
@license ||= License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
end
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
def cache_license
|
||||
if (current_license.detail_with_local_cache == true)
|
||||
return current_license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
@@ -147,7 +131,6 @@ class ActionController::API
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
|
||||
@@ -21,12 +21,17 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get 'get_key' => 'sym_control#get_key'
|
||||
|
||||
#--------- Login/Authentication ------------#
|
||||
get 'auth/:emp_id' => 'home#show', as: :emp_login
|
||||
patch "auth/:emp_id" => 'home#update', as: :emp_login_update
|
||||
get 'login' => 'sessions#index'
|
||||
get 'auth/:emp_id' => 'sessions#show', as: :emp_login
|
||||
patch "auth/:emp_id" => 'sessions#update', as: :emp_login_update
|
||||
|
||||
post 'login' => 'home#create'
|
||||
delete 'logout' => 'home#destroy'
|
||||
get 'dashboard' => 'home#dashboard'
|
||||
post 'login' => 'sessions#create'
|
||||
delete 'logout' => 'sessions#destroy'
|
||||
|
||||
get 'review_license' => 'review_license#index'
|
||||
post 'review_license' => 'review_license#create'
|
||||
|
||||
get 'dashboard' => 'dashboard#index'
|
||||
|
||||
namespace :induties do
|
||||
# resources :assign_in_duties
|
||||
@@ -280,7 +285,6 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get 'sale/:sale_id/:type/payment/others_payment/giftvoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/:method' => 'others_payments#new'
|
||||
|
||||
|
||||
#---------Void --------------#
|
||||
post 'sale/:sale_id/:type/void' => 'void#overall_void'
|
||||
|
||||
@@ -370,6 +374,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
# post 'credit_payment/junctionpay' => 'junction_pay#create'
|
||||
# post 'credit_payment/dinga' => 'dinga#create'
|
||||
# post 'credit_payment/gift_voucher' => 'gift_voucher#create'
|
||||
post 'credit_payment/:method' => 'others_payments#create', :as => 'credit_payment'
|
||||
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment' => "others_payments#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/mpu' => "mpu#index"
|
||||
@@ -386,7 +391,6 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/giftvoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/:method' => 'others_payments#new'
|
||||
|
||||
|
||||
#------------- Start Reservation -------------------#
|
||||
resources :reservation
|
||||
#------------- End Reservation -------------------#
|
||||
@@ -484,6 +488,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
resources :products
|
||||
#lookups
|
||||
resources :lookups
|
||||
#menu_item_groups
|
||||
resources :menu_item_groups
|
||||
#cashier_terminals
|
||||
resources :cashier_terminals
|
||||
#order_job_stations
|
||||
|
||||
Reference in New Issue
Block a user