Test version for DB sync schedule job
This commit is contained in:
parent
f827e8429e
commit
083963af65
|
@ -39,65 +39,15 @@ class ApplicationController < ActionController::Base
|
||||||
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
|
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def auth_failed_in_backend
|
|
||||||
#redirect_to admin_dashboards_url
|
|
||||||
redirect_to root_path
|
|
||||||
end
|
|
||||||
|
|
||||||
# Check if the current_user is admin
|
# Check if the current_user is admin
|
||||||
def is_admin?
|
def is_admin?
|
||||||
current_user.admin? ? true : auth_failed_in_backend
|
redirect_to root_url unless current_user.admin?
|
||||||
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? )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Render the page
|
# Render the page
|
||||||
def render_page(param={})
|
def render_page(id = nil)
|
||||||
if @item
|
if @item
|
||||||
render :text => process_page(@item, param[:id], param), :layout => 'page_layout'
|
render :text => process_page(@item, id), :layout => 'page_layout'
|
||||||
else
|
else
|
||||||
render :text => '404 Not Found'
|
render :text => '404 Not Found'
|
||||||
end
|
end
|
||||||
|
@ -128,8 +78,8 @@ class ApplicationController < ActionController::Base
|
||||||
# set site if exist or create site
|
# set site if exist or create site
|
||||||
@site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []})
|
@site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []})
|
||||||
session[:site] = @site.id
|
session[:site] = @site.id
|
||||||
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
|
@site_in_use_locales = @site.in_use_locales
|
||||||
@site_valid_locales = site_locales_default_head(@site.valid_locales)
|
@site_valid_locales = @site.valid_locales
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_current_item
|
def set_current_item
|
||||||
|
@ -164,14 +114,4 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -3,7 +3,13 @@ class SyncDb
|
||||||
@queue = :high
|
@queue = :high
|
||||||
|
|
||||||
def self.perform()
|
def self.perform()
|
||||||
# sleep 10
|
self.start_sync
|
||||||
puts "DB 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
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,4 +11,4 @@ mid_host = {
|
||||||
:database => "RSS23_NCCU_MIDDLE",
|
:database => "RSS23_NCCU_MIDDLE",
|
||||||
:encoding => "UTF8"
|
:encoding => "UTF8"
|
||||||
}
|
}
|
||||||
#MID_CLIENT = Mysql2::Client.new(mid_host)
|
MID_CLIENT = Mysql2::Client.new(mid_host)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
do_mail_matt:
|
# do_mail_matt:
|
||||||
every: 10s
|
# every: 10s
|
||||||
class: FetchTime
|
# class: FetchTime
|
||||||
args:
|
# args:
|
||||||
description: Runs the perform method in FetchTime
|
# description: Runs the perform method in FetchTime
|
||||||
|
|
||||||
nccu_daily_ldap_sync:
|
nccu_daily_ldap_sync:
|
||||||
cron: * * [0,12] * * *
|
cron: * * [0,12] * * *
|
||||||
class: SyncDb
|
class: SyncDb
|
||||||
args:
|
args:
|
||||||
description: Runs the perform method in SnycDB
|
description: Sync NCCU middle site with Orbit for LDAP data
|
||||||
|
|
||||||
nccu_claender_sync:
|
nccu_claender_sync:
|
||||||
every: 1m
|
cron: * * [0,12] * * *
|
||||||
class: NccuCalendar
|
class: NccuCalendar
|
||||||
args:
|
args:
|
||||||
description: Runs the perform method in NccuCalendar
|
description: Sync NCCU calendar RSS Feeds
|
|
@ -2,6 +2,7 @@
|
||||||
# require 'ruby-debug'
|
# require 'ruby-debug'
|
||||||
|
|
||||||
namespace :mid_site do
|
namespace :mid_site do
|
||||||
|
desc "mid_site Rake task"
|
||||||
attr_from_mid = %w{nccu_id psn_nam ut_cod up_ut_cod eml_adr off_tel_ext sta_num}
|
attr_from_mid = %w{nccu_id psn_nam ut_cod up_ut_cod eml_adr off_tel_ext sta_num}
|
||||||
officer_posgrp_code = %w{02 06 10 05} #from RSS2
|
officer_posgrp_code = %w{02 06 10 05} #from RSS2
|
||||||
admin_role = nil
|
admin_role = nil
|
||||||
|
|
Reference in New Issue