Test version for DB sync schedule job
This commit is contained in:
1 parent
f827e8429e
commit
083963af65
6 files changed
+23
-76
No files matched your search
@@ -39,65 +39,15 @@ class ApplicationController < ActionController::Base
|
||||
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
|
||||
end
|
||||
|
||||
def auth_failed_in_backend
|
||||
#redirect_to admin_dashboards_url
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
# Check if the current_user is admin
|
||||
def is_admin?
|
||||
current_user.admin? ? true : auth_failed_in_backend
|
||||
end
|
||||
|
||||
def is_manager?
|
||||
@module_app.managing_users.include?(current_user) || is_admin?
|
||||
end
|
||||
|
||||
def for_admin_only
|
||||
if is_admin?
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.not_admin")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_manager
|
||||
if is_manager?
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_manager")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_sub_manager
|
||||
if (@module_app.sub_managing_users.include?(current_user) || is_manager?)
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_sub_manager")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_user
|
||||
if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager )
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_authed_user")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def check_object_premission(obj,title)
|
||||
flash[:error] = t("admin.access.denied.object")
|
||||
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? )
|
||||
redirect_to root_url unless current_user.admin?
|
||||
end
|
||||
|
||||
# Render the page
|
||||
def render_page(param={})
|
||||
def render_page(id = nil)
|
||||
if @item
|
||||
render :text => process_page(@item, param[:id], param), :layout => 'page_layout'
|
||||
render :text => process_page(@item, id), :layout => 'page_layout'
|
||||
else
|
||||
render :text => '404 Not Found'
|
||||
end
|
||||
@@ -128,8 +78,8 @@ class ApplicationController < ActionController::Base
|
||||
# set site if exist or create site
|
||||
@site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []})
|
||||
session[:site] = @site.id
|
||||
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
|
||||
@site_valid_locales = site_locales_default_head(@site.valid_locales)
|
||||
@site_in_use_locales = @site.in_use_locales
|
||||
@site_valid_locales = @site.valid_locales
|
||||
end
|
||||
|
||||
def set_current_item
|
||||
@@ -164,14 +114,4 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def site_locales_default_head(locales)
|
||||
if locales[0].eql? I18n.locale.to_s
|
||||
locales
|
||||
else
|
||||
a = Array.new(locales)
|
||||
shift_out = a.delete(I18n.locale.to_s)
|
||||
[shift_out] + a
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
+8
-2
@@ -3,7 +3,13 @@ class SyncDb
|
||||
@queue = :high
|
||||
|
||||
def self.perform()
|
||||
# sleep 10
|
||||
puts "DB Sync"
|
||||
self.start_sync
|
||||
end
|
||||
|
||||
def self.start_sync
|
||||
task = 'mid_site:sync'
|
||||
args = []
|
||||
%x[rake #{task} --trace >> #{Rails.root}/log/rake.log]
|
||||
puts "SyncDb Synced"
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user