NCCU 上傳版本 0709
Merge branch 'nccu0621' Conflicts: Gemfile config/resque.god vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
This commit is contained in:
commit
09d46f2f75
79 files changed
+683
-278
No files matched your search
@@ -0,0 +1,44 @@
|
||||
module OrbitControllerLib
|
||||
module DivisionForDisable
|
||||
# def get_disable_object_by_user(object_class)
|
||||
# if is_admin? or is_manager?
|
||||
# object_class.admin_manager_all
|
||||
# else
|
||||
# object_class.all
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
def get_categories_for_index(object_class,id = nil)
|
||||
class_ref = object_class.constantize
|
||||
ivar_name = "@#{object_class.to_s.underscore.pluralize}"
|
||||
instance_variable_set(ivar_name, [])
|
||||
if(is_manager? || is_admin?)
|
||||
instance_variable_set(ivar_name, (id ? class_ref.admin_manager_all.find(id).to_a : class_ref.admin_manager_all))
|
||||
elsif is_sub_manager?
|
||||
instance_variable_set(ivar_name, (class_ref.all))
|
||||
end
|
||||
instance_variable_get(ivar_name)
|
||||
end
|
||||
|
||||
def get_categorys(object_class,id = nil,func_authed_for_sub_manager = 'submit')
|
||||
class_ref = object_class.constantize
|
||||
# ivar_name = "@#{object_class.to_s.underscore.pluralize}"
|
||||
ivar_name = "@#{object_class.to_s.underscore}s"
|
||||
instance_variable_set(ivar_name, [])
|
||||
@bulletin_categorys = []
|
||||
if(is_manager? || is_admin?)
|
||||
#instance_variable_set(ivar_name, (id ? class_ref.admin_manager_all.find(id).to_a : class_ref.admin_manager_all))
|
||||
instance_variable_set(ivar_name, (id ? class_ref.all.find(id).to_a : class_ref.all))
|
||||
elsif is_sub_manager?
|
||||
instance_variable_set(ivar_name, class_ref.all.authed_for_user(current_user,func_authed_for_sub_manager))
|
||||
end
|
||||
if instance_variable_get(ivar_name).empty? && params[:action] != "index"
|
||||
flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
|
||||
redirect_to :action => :index
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
+27
-1
@@ -1,4 +1,30 @@
|
||||
module OrbitCoreLib
|
||||
module ObjectDisable
|
||||
def self.included(base)
|
||||
|
||||
base.instance_eval("field :disable,type: Boolean,:default => false")
|
||||
base.instance_eval("scope :all,where(disable: false)")
|
||||
base.instance_eval("scope :admin_manager_all,find(:all)")
|
||||
|
||||
base.define_singleton_method :find do |*args|
|
||||
if args ==[:all]
|
||||
unscoped
|
||||
else
|
||||
res = unscoped.find(args)
|
||||
res.count == 1 ? res[0] : res
|
||||
end
|
||||
end
|
||||
|
||||
base.define_singleton_method :first do |*args|
|
||||
all.first
|
||||
end
|
||||
|
||||
base.define_singleton_method :last do |*args|
|
||||
all.last
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
module ObjectAuthable
|
||||
def self.included(base)
|
||||
base.instance_eval("has_many :object_auths,as: :obj_authable,dependent: :delete")
|
||||
@@ -14,7 +40,7 @@ module OrbitCoreLib
|
||||
query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id)
|
||||
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role.id}).excludes(blocked_user_ids: user.id)
|
||||
result = (query1 + query2).uniq
|
||||
result.collect{|t| t.obj_authable}
|
||||
result.collect{|t| t.obj_authable}.delete_if{|val| val==nil}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
require 'resque_scheduler/tasks'
|
||||
# encoding: utf-8
|
||||
|
||||
namespace :data_migration do
|
||||
|
||||
task :add_order_to_announcement_tag_0703 => :environment do
|
||||
AnnouncementTag.first({conditions:{ key: 'students' }}).update_attributes(:order=>1)
|
||||
AnnouncementTag.first({conditions:{ key: 'alumni' }}).update_attributes(:order=>2)
|
||||
AnnouncementTag.first({conditions:{ key: 'employee' }}).update_attributes(:order=>3)
|
||||
AnnouncementTag.first({conditions:{ key: 'guest' }}).update_attributes(:order=>4)
|
||||
end
|
||||
|
||||
task :add_archive_func_to_bulletin_category_0704 => :environment do
|
||||
BulletinCategory.all.each{|bc| bc.disable=false;bc.save!}
|
||||
end
|
||||
|
||||
|
||||
task :add_archive_func_to_news_bulletin_category_0704 => :environment do
|
||||
NewsBulletinCategory.all.each{|bc| bc.disable=false;bc.save!}
|
||||
end
|
||||
|
||||
end
|
||||
@@ -36,6 +36,7 @@ namespace :mid_site do
|
||||
local_need_remove = User.all.collect{|t| t.nccu_id rescue nil}.uniq.delete_if {|x| x == nil} - remote_list
|
||||
desc "Going to delete User with IDs: #{local_need_remove.inspect}"
|
||||
local_need_remove = User.excludes(nccu_ldap_uid: test_account_ldap_id ).collect{|t| t.nccu_ldap_uid rescue nil}.uniq.delete_if {|x| x == nil} - remote_list
|
||||
AppManager.all.collect{|am| am if am.user.nil? }.delete_if {|x| x == nil}.each{|am| am.destroy}
|
||||
desc "Deletion completed! \n"
|
||||
|
||||
#starting update user
|
||||
@@ -77,6 +78,7 @@ namespace :mid_site do
|
||||
|
||||
local_user.save!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user