diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 494b497e..fb82774e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/jobs/sync_db.rb b/app/jobs/sync_db.rb index f6458204..d4bda790 100644 --- a/app/jobs/sync_db.rb +++ b/app/jobs/sync_db.rb @@ -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 diff --git a/config/initializers/middle_site_connection.rb b/config/initializers/middle_site_connection.rb index 5dddcdcb..4f20995a 100644 --- a/config/initializers/middle_site_connection.rb +++ b/config/initializers/middle_site_connection.rb @@ -11,4 +11,4 @@ mid_host = { :database => "RSS23_NCCU_MIDDLE", :encoding => "UTF8" } -#MID_CLIENT = Mysql2::Client.new(mid_host) +MID_CLIENT = Mysql2::Client.new(mid_host) diff --git a/config/resque_schedule.yml b/config/resque_schedule.yml index 1f491898..6929152e 100644 --- a/config/resque_schedule.yml +++ b/config/resque_schedule.yml @@ -1,17 +1,17 @@ -do_mail_matt: - every: 10s - class: FetchTime - args: - description: Runs the perform method in FetchTime +# do_mail_matt: +# every: 10s +# class: FetchTime +# args: +# description: Runs the perform method in FetchTime nccu_daily_ldap_sync: cron: * * [0,12] * * * class: SyncDb args: - description: Runs the perform method in SnycDB + description: Sync NCCU middle site with Orbit for LDAP data nccu_claender_sync: - every: 1m + cron: * * [0,12] * * * class: NccuCalendar args: - description: Runs the perform method in NccuCalendar \ No newline at end of file + description: Sync NCCU calendar RSS Feeds \ No newline at end of file diff --git a/dump.rdb b/dump.rdb index a4a56dc0..a3c1b42c 100644 Binary files a/dump.rdb and b/dump.rdb differ diff --git a/lib/tasks/mid_site_sync.rake b/lib/tasks/mid_site_sync.rake index 76660bf8..89684985 100644 --- a/lib/tasks/mid_site_sync.rake +++ b/lib/tasks/mid_site_sync.rake @@ -2,6 +2,7 @@ # require 'ruby-debug' 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} officer_posgrp_code = %w{02 06 10 05} #from RSS2 admin_role = nil