forked from saurabh/orbit4-5
module store changes
This commit is contained in:
parent
c8d395aca1
commit
6e27bbd483
|
@ -43,6 +43,10 @@ class StoreApiController < ApplicationController
|
||||||
render :json => {"success" => true}.to_json
|
render :json => {"success" => true}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_license_denied
|
||||||
|
render :layout => "back_end"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def bundle_install
|
def bundle_install
|
||||||
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update && bundle` }
|
Bundler.with_clean_env { `cd #{Rails.root} && BUNDLE_GEMFILE=downloaded_extensions.rb bundle update && bundle` }
|
||||||
|
|
|
@ -172,8 +172,15 @@ module OrbitBackendHelper
|
||||||
http = Net::HTTP.new(uri.host,uri.port)
|
http = Net::HTTP.new(uri.host,uri.port)
|
||||||
request = Net::HTTP::Get.new("/site/permissions")
|
request = Net::HTTP::Get.new("/site/permissions")
|
||||||
request.body = params_to_send.to_query
|
request.body = params_to_send.to_query
|
||||||
response = http.request(request)
|
response = http.request(request) rescue nil
|
||||||
data = JSON.parse(response.body)
|
if response.nil?
|
||||||
|
data = {}
|
||||||
|
data["message"] = "Could not connect to the store."
|
||||||
|
data["error"] = "CONNECTION_REFUSED"
|
||||||
|
data["success"] = false
|
||||||
|
else
|
||||||
|
data = JSON.parse(response.body)
|
||||||
|
end
|
||||||
if !data["success"]
|
if !data["success"]
|
||||||
case data["error"]
|
case data["error"]
|
||||||
when "INVALID_SITE_TOKEN"
|
when "INVALID_SITE_TOKEN"
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ModuleApp
|
||||||
field :widget_methods
|
field :widget_methods
|
||||||
field :desktop_enabled, type: Boolean, default: false
|
field :desktop_enabled, type: Boolean, default: false
|
||||||
field :widget_settings
|
field :widget_settings
|
||||||
|
field :store_permission_granted, type: Boolean, default: false
|
||||||
|
|
||||||
has_many :categories, dependent: :destroy, :autosave => true
|
has_many :categories, dependent: :destroy, :autosave => true
|
||||||
has_and_belongs_to_many :tags, dependent: :destroy, :autosave => true
|
has_and_belongs_to_many :tags, dependent: :destroy, :autosave => true
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
class OrbitStore
|
class OrbitStore
|
||||||
URL = "http://store.tp.rulingcom.com"
|
URL = "http://store.tp.rulingcom.com"
|
||||||
|
MODULE_EXCEPTIONS = ["category","tag","authorization"]
|
||||||
end
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
<h3>License Denied.</h3>
|
||||||
|
<p>Please contact <a href="http://www.rulingdigital.com">www.rulingdigital.com</a>.</p>
|
|
@ -5,6 +5,7 @@ require File.expand_path('../application', __FILE__)
|
||||||
Orbit::Application.initialize!
|
Orbit::Application.initialize!
|
||||||
Orbit::Application.config.secret_key_base = 'acc6ffc5a7d360c9cf2a7bdb4ddf9a897942ec6767413a5c0324a0fa8b86197a96298288a66bd46d8770d8b6edf509aad65716961c2c364ce006b475e6cfd418'
|
Orbit::Application.config.secret_key_base = 'acc6ffc5a7d360c9cf2a7bdb4ddf9a897942ec6767413a5c0324a0fa8b86197a96298288a66bd46d8770d8b6edf509aad65716961c2c364ce006b475e6cfd418'
|
||||||
OrbitApp.cleanup_modules
|
OrbitApp.cleanup_modules
|
||||||
|
OrbitApp.check_module_permissions
|
||||||
|
|
||||||
if Site.count == 0
|
if Site.count == 0
|
||||||
site = Site.new
|
site = Site.new
|
||||||
|
|
|
@ -16,6 +16,7 @@ Orbit::Application.routes.draw do
|
||||||
get "/page_parts/getwidgets" => "page_parts#getwidgets"
|
get "/page_parts/getwidgets" => "page_parts#getwidgets"
|
||||||
get "/page_parts/info" => "page_parts#info"
|
get "/page_parts/info" => "page_parts#info"
|
||||||
get "/page_parts/edit_sub_part" => "page_parts#edit_sub_part"
|
get "/page_parts/edit_sub_part" => "page_parts#edit_sub_part"
|
||||||
|
get "/admin/license_denied" => "store_api#render_license_denied"
|
||||||
|
|
||||||
resources :pages
|
resources :pages
|
||||||
resources :page_parts do
|
resources :page_parts do
|
||||||
|
@ -197,7 +198,7 @@ Orbit::Application.routes.draw do
|
||||||
get 'check_updates'
|
get 'check_updates'
|
||||||
get 'update_orbit'
|
get 'update_orbit'
|
||||||
get 'restart_server'
|
get 'restart_server'
|
||||||
get 'delete_mail_log'
|
get 'delete_mail_log'
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :designs do
|
resources :designs do
|
||||||
|
|
|
@ -13,12 +13,14 @@ module SideBarRenderer
|
||||||
@app_available_for = af
|
@app_available_for = af
|
||||||
if display?
|
if display?
|
||||||
content_tag :div, class: "sub-nav-block #{@icon_class}" do
|
content_tag :div, class: "sub-nav-block #{@icon_class}" do
|
||||||
concat content_tag :h4, I18n.t(@head_label)
|
if @belong_module_app.store_permission_granted
|
||||||
concat (content_tag :ul, class: "nav nav-list" do
|
concat content_tag :h4, I18n.t(@head_label)
|
||||||
@context_links.sort_by {| obj | obj.priority}.map{ |link|
|
concat (content_tag :ul, class: "nav nav-list" do
|
||||||
link.render(request, params, @current_module_app, @current_user, @belong_module_app, link.get_active_action, link.available_for)
|
@context_links.sort_by {| obj | obj.priority}.map{ |link|
|
||||||
}.join.html_safe
|
link.render(request, params, @current_module_app, @current_user, @belong_module_app, link.get_active_action, link.available_for)
|
||||||
end)
|
}.join.html_safe
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,9 +35,17 @@ module SideBarRenderer
|
||||||
@app_available_for = available_for
|
@app_available_for = available_for
|
||||||
if display?
|
if display?
|
||||||
content_tag :li, class: (module_sidebar_active? ? 'active' : nil) do
|
content_tag :li, class: (module_sidebar_active? ? 'active' : nil) do
|
||||||
link_to Rails.application.routes.url_helpers.send(@head_link) do
|
if @belong_module_app.store_permission_granted
|
||||||
content_tag :span do
|
link_to Rails.application.routes.url_helpers.send(@head_link) do
|
||||||
content_tag(:i, nil, class: @icon_class)
|
content_tag :span do
|
||||||
|
content_tag(:i, nil, class: @icon_class)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
link_to "/admin/license_denied" do
|
||||||
|
content_tag :span do
|
||||||
|
content_tag(:i, nil, class: @icon_class + " text-error")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,5 +20,46 @@ module OrbitApp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_module_permissions
|
||||||
|
store_token = Site.first.store_token
|
||||||
|
module_apps = ModuleApp.all
|
||||||
|
exceptions = OrbitStore::MODULE_EXCEPTIONS
|
||||||
|
if !store_token.nil?
|
||||||
|
ids = []
|
||||||
|
module_index = {}
|
||||||
|
module_apps.each do |ma|
|
||||||
|
ids << ma.key
|
||||||
|
module_index[ma.key] = ma
|
||||||
|
end
|
||||||
|
params_to_send = {'store_token' => store_token, "apps" => ids}
|
||||||
|
uri = URI.parse(OrbitStore::URL)
|
||||||
|
http = Net::HTTP.new(uri.host,uri.port)
|
||||||
|
request = Net::HTTP::Post.new("/store/check_module_permissions")
|
||||||
|
request.body = params_to_send.to_query
|
||||||
|
response = http.request(request) rescue nil
|
||||||
|
if !response.nil?
|
||||||
|
data = JSON.parse(response.body)
|
||||||
|
if response.code == "200"
|
||||||
|
permissions = data["permissions"]
|
||||||
|
permissions.each do |permission|
|
||||||
|
ma = module_index[permission["app"]]
|
||||||
|
ma.store_permission_granted = (exceptions.include?(ma.key) ? true : permission["granted"])
|
||||||
|
ma.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
module_apps.each do |ma|
|
||||||
|
ma.store_permission_granted = (exceptions.include?(ma.key) ? true : false)
|
||||||
|
ma.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
module_apps.each do |ma|
|
||||||
|
ma.store_permission_granted = (exceptions.include?(ma.key) ? true : false)
|
||||||
|
ma.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -62,7 +62,11 @@ module OrbitCoreLib
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if !@module_app.nil?
|
if !@module_app.nil?
|
||||||
check_user_can_use
|
if @module_app.store_permission_granted || params["controller"] == "admin/authorizations"
|
||||||
|
check_user_can_use
|
||||||
|
else
|
||||||
|
redirect_to admin_license_denied_path
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if current_user.nil? || !current_user.is_admin?
|
if current_user.nil? || !current_user.is_admin?
|
||||||
if params["controller"] != "admin/assets"
|
if params["controller"] != "admin/assets"
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
namespace :register_with_store do
|
||||||
|
task :register,[:arg] => :environment do |task,args|
|
||||||
|
modules = ModuleApp.all
|
||||||
|
ids = modules.collect{|ma| ma.key}
|
||||||
|
store_token = Site.first.store_token
|
||||||
|
module_apps = ModuleApp.all
|
||||||
|
exceptions = OrbitStore::MODULE_EXCEPTIONS
|
||||||
|
if !store_token.nil?
|
||||||
|
params_to_send = {'store_token' => store_token, "apps" => ids}
|
||||||
|
uri = URI.parse(OrbitStore::URL)
|
||||||
|
http = Net::HTTP.new(uri.host,uri.port)
|
||||||
|
request = Net::HTTP::Post.new("/store/register_old_sites_modules")
|
||||||
|
request.body = params_to_send.to_query
|
||||||
|
response = http.request(request) rescue nil
|
||||||
|
if response.nil?
|
||||||
|
puts "Cannot connect to store."
|
||||||
|
else
|
||||||
|
puts "All modules registered."
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "Cannot register modules, site is not registered with store."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue