Merge branch 'new_member' of github.com:Rulingcom/orbit into new_member

Conflicts:
	app/helpers/attribute_fields_helper.rb
	app/views/admin/infos/_form.html.erb
	config/locales/zh_tw.yml
This commit is contained in:
Matthew K. Fu JuYuan committed 2012-11-16 15:42:39 +08:00
commit b4a2737407
373 files changed
+10342 -6551

No files matched your search

+14 -1
View File
@@ -1,4 +1,17 @@
module OrbitCoreLib
module Preview
def self.included(base)
# base.instance_eval("field :is_preview,type: Boolean,:default => false")
# base.instance_eval("scope :not_preview,where(:is_preview=>false)")
base.class_eval ("
def to_preview
raise 'Developer,please override to_preview method'
end
")
end
end
module BelongsToCategoryMayDisable
def self.included(base)
base.instance_eval("belongs_to :#{base::BelongsToCategory.to_s}")
@@ -79,7 +92,7 @@ module OrbitCoreLib
authed_users(title).include?(User.current)
end
def app_auth
def module_app
ModuleApp.first(conditions: {:title => self.class::APP_NAME} )
end
+22
View File
@@ -0,0 +1,22 @@
module ParserLayoutWidget
require 'nokogiri'
def parse_widget_for_images(widget)
content = widget.widget_layout.file.read.force_encoding("UTF-8")
widge = Nokogiri::HTML(content)
a = []
b = []
widge.css('.widget_image').each do |page_image|
image = widget.images.where( file: File.basename(page_image['src']))[0]
a << page_image['src']
b << image.file
image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image
end
a.each_with_index do |img,i|
content = content.gsub(img,b[i].to_s)
end
widget.widget_layout.update_attributes(:body => content)
end
end
+11
View File
@@ -0,0 +1,11 @@
# encoding: utf-8
namespace :index do
task :rebuild => :environment do
Sunspot.remove_all!
Sunspot.commit
Sunspot.index NewsBulletin.all
Sunspot.index Bulletin.all
Sunspot.commit
end
end
+1 -2
View File
@@ -9,7 +9,7 @@ namespace :mid_site do
admin_role = nil
sub_role = nil
test_account_ldap_id ='139716'
#MiddleSiteConnection.establish
MiddleSiteConnection.establish
task :sync => :environment do
info_profile = Info.first(conditions: {:key => 'profile'})
@@ -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
+12
View File
@@ -355,5 +355,17 @@ namespace :migrate do
p 'End Site'
end
task :news_p => :environment do
news_bulletins = NewsBulletin.admin_manager_all rescue nil
i = 1
news_bulletins.each do |news|
p "#{i}/#{news_bulletins.size} - #{news.id}"
news.subtitle_translations = {'en' => (news.subtitle_translations['en'].gsub(/^\<p\>/, '').gsub(/\<\/p\>$/, '') rescue ''), 'zh_tw' => (news.subtitle_translations['zh_tw'].gsub(/^\<p\>/, '').gsub(/\<\/p\>$/, '') rescue nil)}
p news.save(:validate => false) if news.changed?
i += 1
end if news_bulletins
end
end
+103
View File
@@ -0,0 +1,103 @@
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
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
task :add_nccu_account_1016 => :environment do
a = ["waynedd@nccu.edu.tw","sfchang@nccu.edu.tw","kyokolin@nccu.edu.tw","sfaylin@nccu.edu.tw","jinyulin@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
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
task :consolidate_object_auth => :environment do
ObjectAuth.all.each{|t| t.save}
end
end