From ae48ab5cbd273a37d2f9c10f68d82cafe9d16cdc Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 4 Oct 2012 15:53:42 +0800 Subject: [PATCH 1/8] clean commit --- .../panel/announcement/back_end/bulletins_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index b2316ef72..46b74c0ac 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -18,7 +18,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController bulletin = Bulletin.new params @preview_obj = bulletin.to_preview @preview_obj.save - render '/shared/preview/preview.html.erb', :layout=>false + render '/shared/preview/preview.html.erb',:layout=>false end def index From e67ca84282ffb5fb8ce127b1b45d92aa5509951f Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 4 Oct 2012 18:20:21 +0800 Subject: [PATCH 2/8] object_auth change to reload --- .../admin/object_auths_new_interface_controller.rb | 3 +-- app/models/object_auth.rb | 4 ++++ .../admin/object_auths_new_interface/setting.html.erb | 9 ++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb index 66eeec3ae..69e944295 100644 --- a/app/controllers/admin/object_auths_new_interface_controller.rb +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -6,7 +6,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController def setting @sys_users = User.all(conditions: {admin: false}).includes(:avatar) @ob_auth = ObjectAuth.find params[:object_auth_id] - @options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] } + @options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] } @users_array = @ob_auth.privilege_users rescue [] respond_to do |format| @@ -73,7 +73,6 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController end def setup_vars - # binding.pry if request.env['HTTP_REFERER'].split('/')[4] == "object_auths" @app_key = params[:app_key] else diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index d5cc48de5..960509f05 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -5,6 +5,10 @@ class ObjectAuth < PrototypeAuth after_save :check_user_has_app_auth # > - Something.find_with_auth(query) # > - or Something.find(query).auth + def siblings + ObjectAuth.where({obj_authable_type: obj_authable_type,title: title}) + end + def auth_obj class_obj = eval(self.obj_authable_type) class_obj.find self.obj_authable_id diff --git a/app/views/admin/object_auths_new_interface/setting.html.erb b/app/views/admin/object_auths_new_interface/setting.html.erb index 709377314..22c7fd8e7 100644 --- a/app/views/admin/object_auths_new_interface/setting.html.erb +++ b/app/views/admin/object_auths_new_interface/setting.html.erb @@ -45,13 +45,8 @@ $(document).ready(function() { } }); - $('#category_id').change(function() { - $.ajax({ - type: 'GET', - dataType: "script", - url:$(this).parents("from").attr("href"), - data:$(this).parents("form").serialize() - }); + $('#ob_auth_id').change(function() { + window.location.href = "/admin/object_auths/"+$(this).val()+"/new_interface?app_key="+$("#app_key").val(); }); }); \ No newline at end of file From 67bd68d492fa0131934a5761191e3fb8d5ebd857 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 8 Oct 2012 10:11:45 +0800 Subject: [PATCH 3/8] harry's js fix --- app/assets/javascripts/inc/search.js | 60 +++++++++++++++++----------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/inc/search.js b/app/assets/javascripts/inc/search.js index 50f3835fb..e8bc84053 100644 --- a/app/assets/javascripts/inc/search.js +++ b/app/assets/javascripts/inc/search.js @@ -4,33 +4,45 @@ //extended jquery to search fast. $.extend($.expr[':'], { - 'containsi': function (elem, i, match, array) { - return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; - } + 'containsi': function (elem, i, match, array) { + return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; + } }); var interval,sval; $(document).ready(function(){ - $("#user_filter").keyup(function(e){ - if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){ - sval = $(this).val(); - $(".checkbox").popover("hide"); - $("div.checkblock").hide(); - clearInterval(interval); - interval = setInterval(waitForSearch,1000); - } - }) + $("#user_filter").keyup(function(e){ + if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){ + sval = $(this).val(); + $(".checkbox").popover("hide"); + $("div.checkblock").hide(); + clearInterval(interval); + interval = setInterval(waitForSearch,1000); + } + }) }) var waitForSearch = function(){ - if(sval){ - var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length - if(totalfoundbyname!=0){ - $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); - }else if(totalfoundbyname==0){ - $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); - } - }else{ - $(".checkbox").popover('hide'); - $("div.checkblock").show(); - } - clearInterval(interval); + if(sval){ + var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range + var re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); + if ((re1.test(sval) && (re2.test(sval)))){ + + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:contains("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:contains("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:contains("+sval+")").parent().show(); + } + }else{ + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); + } + } + }else{ + $(".checkbox").popover('hide'); + $("div.checkblock").show(); + } + clearInterval(interval); } \ No newline at end of file From 4a5fc47c0ad04dce1324cbd231952c1357d14d42 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 8 Oct 2012 10:35:11 +0800 Subject: [PATCH 4/8] NCCU maintenance rake task --- lib/tasks/nccu.rake | 62 ++++++++++++++++++++++++++++++++++++++++ public/assets/.gitignore | 0 2 files changed, 62 insertions(+) create mode 100644 lib/tasks/nccu.rake delete mode 100644 public/assets/.gitignore diff --git a/lib/tasks/nccu.rake b/lib/tasks/nccu.rake new file mode 100644 index 000000000..5c20f27cb --- /dev/null +++ b/lib/tasks/nccu.rake @@ -0,0 +1,62 @@ +namespace :nccu do + task :copy_news_object_auth_to_all_of_news_cate => :environment do + # users = user_data.collect do |login_uid| + # nccu_id = get_nccu_id_from_mid_site(login_uid) + # resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id })) + # end + + + nbc = NewsBulletinCategory.first({conditions: "administration"}) + users_ary = Array.new(ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: nbc.id}}).privilege_user_ids) + to_nbcs = NewsBulletinCategory.where(:key.ne=> 'administration') + to_nbcs.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_user_ids = users_ary + oa.save + end + end + + task :apply_180_news_cate_auth_to_171 => :environment do + ldap_id_data = [3603,100212, 8151, 3471, 145232, 133380, 133222, 127983, 127977, 127692, 123617, 123566, 58483, 48234, 29237, 9253, 8948, 8703, 8251, 7336, 7242, 7220, 6912, 6603, 6459, 5475, 3643, 3641, 3559, 3310, 3248, 2672, 2531, 1633, 1521, 1516, 145571, 20610, 123604, 100211, 39571, 29479, 8013, 6968, 5868, 5724, 5401, 4369, 3573, 3377, 2918, 2822, 2309, 2134, 1731, 1527] + users_ary = Array.new(User.where(:nccu_ldap_uid.in => ldap_id_data )) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users = users_ary + oa.save + end + end + + task :remove_3603 => :environment do + user_email = 'tu65@nccu.edu.tw' + user = User.first({conditions:{email: user_email}}) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users.delete_if{|t| t == user} + oa.save + end + + key = 'Announcement' + bc = BulletinCategory.first({conditions:{key: key}}) + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "BulletinCategory",obj_authable_id: bc.id}}) + oa.privilege_users.delete_if{|t| t == user} + oa.save + end + + task :add_nccu_account_1008 => :environment do + a = ['yjlin3@nccu.edu.tw','liwen@nccu.edu.tw','yhc@nccu.edu.tw','kenliu@nccu.edu.tw','cfc@nccu.edu.tw','jasper@nccu.edu.tw','donghe@nccu.edu.tw','frees712@nccu.edu.tw','jeanch@nccu.edu.tw','posty@nccu.edu.tw','yiting@nccu.edu.tw','frank997@nccu.edu.tw'] + users_ary = User.any_in(email: a) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + end + + key = 'Announcement' + bc = BulletinCategory.first({conditions:{key: key}}) + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "BulletinCategory",obj_authable_id: bc.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + + end + +end \ No newline at end of file diff --git a/public/assets/.gitignore b/public/assets/.gitignore deleted file mode 100644 index e69de29bb..000000000 From cf68022d4f4b32e915a92e3c3f577116176a4e4c Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 8 Oct 2012 11:26:24 +0800 Subject: [PATCH 5/8] fix resque server stop --- config/initializers/resque.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb index 62de3fa45..0fa2a4c6f 100644 --- a/config/initializers/resque.rb +++ b/config/initializers/resque.rb @@ -1,9 +1,9 @@ require 'resque_scheduler' -# require 'resque_scheduler/server' +require 'resque_scheduler/server' # require 'yaml' Resque.redis = 'localhost:6379' -#Resque.redis.namespace = "resque:SchedulerExample" +Resque.redis.namespace = "resque:nccu" # If you want to be able to dynamically change the schedule, # uncomment this line. A dynamic schedule can be updated via the From 0663e43be75307bf96016ee6035a3edf25c23b09 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 8 Oct 2012 16:02:33 +0800 Subject: [PATCH 6/8] fix for web_resource tool bar --- .../panel/web_resource/back_end/web_links/_form.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb index d657ce7b1..752a64eb0 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb @@ -1,3 +1,4 @@ +
<% # encoding: utf-8 %> <%= f.error_messages %> @@ -104,4 +105,5 @@
<%= f.submit t('submit'), :class=>'btn btn-primary' %> <%= link_to t('cancel'), get_go_back, :class=>"btn" %> -
\ No newline at end of file +
+ \ No newline at end of file From 89b1aace8acda29b079816732796d884764e30cf Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 8 Oct 2012 16:42:49 +0800 Subject: [PATCH 7/8] fix for rescue job failed on 171 --- config/initializers/resque.rb | 2 +- lib/tasks/mid_site_sync.rake | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb index 0fa2a4c6f..bd7a91fe5 100644 --- a/config/initializers/resque.rb +++ b/config/initializers/resque.rb @@ -3,7 +3,7 @@ require 'resque_scheduler/server' # require 'yaml' Resque.redis = 'localhost:6379' -Resque.redis.namespace = "resque:nccu" +Resque.redis.namespace = "resque" # If you want to be able to dynamically change the schedule, # uncomment this line. A dynamic schedule can be updated via the diff --git a/lib/tasks/mid_site_sync.rake b/lib/tasks/mid_site_sync.rake index 707a609b3..e3ee411b0 100644 --- a/lib/tasks/mid_site_sync.rake +++ b/lib/tasks/mid_site_sync.rake @@ -77,7 +77,6 @@ namespace :mid_site do local_user.save! end sys_users = User.all(conditions: {admin: false}).includes(:avatar).to_a - Rails.cache.write('user_setting', sys_users) end From d027cf8e6a6ccc7cc518b9d3b38be98399dde8bc Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 9 Oct 2012 14:40:28 +0800 Subject: [PATCH 8/8] add new data from NCCU --- lib/tasks/nccu.rake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/tasks/nccu.rake b/lib/tasks/nccu.rake index 5c20f27cb..8cae04e20 100644 --- a/lib/tasks/nccu.rake +++ b/lib/tasks/nccu.rake @@ -59,4 +59,29 @@ namespace :nccu do end + task :add_nccu_account_1009 => :environment do + a = ["blannytg@nccu.edu.tw","yucca@nccu.edu.tw","fish14@nccu.edu.tw","amanda13@nccu.edu.tw"] + users_ary = User.any_in(email: a) + NewsBulletinCategory.all.each do |cate| + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "NewsBulletinCategory",obj_authable_id: cate.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + end + + a=["annieayu@nccu.edu.tw","blannytg@nccu.edu.tw","yucca@nccu.edu.tw","amanda13@nccu.edu.tw"] + users_ary = User.any_in(email: a) + key = 'Announcement' + bc = BulletinCategory.first({conditions:{key: key}}) + oa = ObjectAuth.first({conditions:{title: "submit",obj_authable_type: "BulletinCategory",obj_authable_id: bc.id}}) + oa.privilege_users = oa.privilege_users + users_ary + oa.save + + end + + + + + + + end \ No newline at end of file