- <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => user.cache_dept[I18n.locale.to_s]},:class=>"checkbox clear" do %>
+
+ <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => (user.cache_dept[I18n.locale.to_s] rescue '')},:class=>"checkbox clear" do %>
diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb
index e68742938..0d22eac87 100644
--- a/config/initializers/load_config.rb
+++ b/config/initializers/load_config.rb
@@ -1 +1,2 @@
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]
+LDAP_CONFIG = YAML.load_file("#{Rails.root}/config/ldap.yml")[Rails.env]
\ No newline at end of file
diff --git a/config/initializers/nccu_ldap_connection.rb b/config/initializers/nccu_ldap_connection.rb
index 35e9ded8f..00e033670 100644
--- a/config/initializers/nccu_ldap_connection.rb
+++ b/config/initializers/nccu_ldap_connection.rb
@@ -6,20 +6,11 @@ $nccu_ldap_connection
module NccuLdapConnection
BASE = 'ou=People,dc=nccu,dc=edu,dc=tw'
- @ldap_host = {
- :host => '127.0.0.1', #140.119.166.23 or 127.0.0.1
- :port => 8001, #389 or 8001
- # :filter => "(uid=#{login_uid})",
- # :base => "ou=People,dc=nccu,dc=edu,dc=tw",
- :authenticate_info => "cn=uccn,ou=profile,dc=nccu,dc=edu,dc=tw",
- :authenticate_pwd => "nccu2ucc"
- }
-
def self.establish
- $nccu_ldap_connection = Net::LDAP.new
- $nccu_ldap_connection.port = @ldap_host[:port]
- $nccu_ldap_connection.host = @ldap_host[:host]
- $nccu_ldap_connection.authenticate(@ldap_host[:authenticate_info],@ldap_host[:authenticate_pwd])
+ $nccu_ldap_connection = Net::LDAP.new
+ $nccu_ldap_connection.port =LDAP_CONFIG["port"]
+ $nccu_ldap_connection.host = LDAP_CONFIG["host"]
+ $nccu_ldap_connection.authenticate(LDAP_CONFIG["authenticate_info"],LDAP_CONFIG["authenticate_pwd"])
end
end
\ No newline at end of file
diff --git a/config/ldap.yml b/config/ldap.yml
new file mode 100644
index 000000000..5c48fc1ab
--- /dev/null
+++ b/config/ldap.yml
@@ -0,0 +1,12 @@
+defaults: &defaults
+ authenticate_info: 'cn=uccn,ou=profile,dc=nccu,dc=edu,dc=tw'
+ authenticate_pwd: 'nccu2ucc'
+
+development:
+ <<: *defaults
+ host: '127.0.0.1'
+ port: 8001
+production:
+ <<: *defaults
+ host: '140.119.166.23'
+ port: 389
diff --git a/config/locales/en.yml b/config/locales/en.yml
index fd08be499..054d1c230 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -289,4 +289,7 @@ en:
modal:
close: Close
preview: Preview
-
+ sys:
+ not_previewable: "Preview not support"
+ limit_of_upload_file_size: "Upload file must be less than: %{best_size}"
+
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 0eb12ba13..098772343 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -508,3 +508,10 @@ zh_tw:
modal:
close: "關閉"
preview: "預覽"
+ sys:
+ not_previewable: "不支援預覽"
+ limit_of_upload_file_size: "上傳檔案大小限制: %{best_size}"
+
+ object_disable:
+ change_to_true: "設為停用"
+ change_to_false: "重新啓用"
\ No newline at end of file
diff --git a/config/resque.god b/config/resque.god
index 767cc47f5..7622576cc 100644
--- a/config/resque.god
+++ b/config/resque.god
@@ -1,20 +1,31 @@
-rails_env = 'development' #ENV['RAILS_ENV'] || "production"
-rails_root = ENV['RAILS_ROOT'] || "/Users/kaito/Documents/MyWorkspeace/NCCU"
+#developer pls change here
+rails_root = "/home/nccu/NCCU/" #keep this blank when development
+
+development_uid = 'kaito' #when dev
+development_gid = 'staff' #when dev
+
+#rails_env = "developement"
+rails_env = "production"
+
+development_rails_root = File.expand_path("..",File.dirname(__FILE__))
+#rails_root = (rails_env == 'production' )? production_rails_root : development_rails_root
num_workers = rails_env == 'production' ? 5 : 2
num_workers.times do |num|
God.watch do |w|
- w.dir = "#{rails_root}"
- w.log = "#{rails_root}/log/myprocess.log"
- w.name = "resque-#{num}"
- w.group = 'resque'
- w.interval = 30.seconds
- p "/usr/bin/rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}"
-# w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
- w.start = "rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}"
- w.uid = 'kaito'
- w.gid = 'staff'
+ w.dir = rails_root
+ w.name = "resque-#{num}"
+ w.group = 'resque'
+
+ w.interval = 30.seconds
+ w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
+ w.start = "rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}"
+
+ w.uid = (rails_env == 'production' )? "root" : development_uid
+ w.gid = (rails_env == 'production' )? "root" : development_gid
+
+ w.log = (rails_env == 'production' )? "/var/log/#{w.name}.log":"#{rails_root}/log/#{w.name}.log"
# restart if memory gets too high
w.transition(:up, :restart) do |on|
@@ -53,4 +64,5 @@ num_workers.times do |num|
end
end
end
-end
\ No newline at end of file
+end
+
diff --git a/config/resque_schedule.god b/config/resque_schedule.god
new file mode 100644
index 000000000..34a6dff8c
--- /dev/null
+++ b/config/resque_schedule.god
@@ -0,0 +1,63 @@
+#developer pls change here
+rails_root = "/home/nccu/NCCU/" #keep this blank when development
+
+development_uid = 'kaito' #when dev
+development_gid = 'staff' #when dev
+
+#rails_env = "developement"
+rails_env = "production"
+
+development_rails_root = File.expand_path("..",File.dirname(__FILE__))
+#rails_root = (rails_env == 'production' )? production_rails_root : development_rails_root
+
+ God.watch do |w|
+ w.dir = rails_root
+ w.name = "resque-scheduler"
+ w.group = 'resque'
+ w.interval = 30.seconds
+ w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
+ w.start = "rake -f #{rails_root}/Rakefile resque:scheduler RAILS_ENV=#{rails_env}"
+
+ w.uid = (rails_env == 'production' )? "root" : development_uid
+ w.gid = (rails_env == 'production' )? "root" : development_gid
+
+ w.log = (rails_env == 'production' )? "/var/log/#{w.name}.log":"#{rails_root}/log/#{w.name}.log"
+
+ # restart if memory gets too high
+ w.transition(:up, :restart) do |on|
+ on.condition(:memory_usage) do |c|
+ c.above = 350.megabytes
+ c.times = 2
+ end
+ end
+
+ # determine the state on startup
+ w.transition(:init, { true => :up, false => :start }) do |on|
+ on.condition(:process_running) do |c|
+ c.running = true
+ end
+ end
+
+ # determine when process has finished starting
+ w.transition([:start, :restart], :up) do |on|
+ on.condition(:process_running) do |c|
+ c.running = true
+ c.interval = 5.seconds
+ end
+
+ # failsafe
+ on.condition(:tries) do |c|
+ c.times = 5
+ c.transition = :start
+ c.interval = 5.seconds
+ end
+ end
+
+ # start if process is not running
+ w.transition(:up, :start) do |on|
+ on.condition(:process_running) do |c|
+ c.running = false
+ end
+ end
+ end
+
diff --git a/config/resque_schedule.yml b/config/resque_schedule.yml
index 27af98fa4..67d006ede 100644
--- a/config/resque_schedule.yml
+++ b/config/resque_schedule.yml
@@ -5,19 +5,19 @@
# description: Runs the perform method in FetchTime
nccu_daily_ldap_sync:
- cron: * * [0,12] * * *
+ cron: 0 0 [0,12] * * *
class: SyncDb
args:
description: Sync NCCU middle site with Orbit for LDAP data
nccu_daily_backup:
- cron: * * 3 * * *
+ cron: 0 0 3 * * *
class: BackupServer
args:
description: Backup NCCU site
nccu_claender_sync:
- cron: * * [0,12] * * *
+ cron: 0 0 [0,12] * * *
class: NccuCalendar
args:
description: Sync NCCU calendar RSS Feeds
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 75fa6142b..40e82749e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -140,7 +140,8 @@ Orbit::Application.routes.draw do
}
# routes for gridfs files
- match "/gridfs/*path" => "gridfs#serve"
+ match "/gridfs/*path" => "gridfs#serve"
+
# match "/images/*path" => "gridfs#serve_images"
# match "/admin/pages/images/*path" => "gridfs#serve_images"
diff --git a/lib/orbit_controller_lib.rb b/lib/orbit_controller_lib.rb
new file mode 100644
index 000000000..e8fd8e051
--- /dev/null
+++ b/lib/orbit_controller_lib.rb
@@ -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
diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb
index f3cd2cd51..5c32e507f 100644
--- a/lib/orbit_core_lib.rb
+++ b/lib/orbit_core_lib.rb
@@ -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
diff --git a/lib/tasks/data_migration.rake b/lib/tasks/data_migration.rake
new file mode 100644
index 000000000..ff132c4ab
--- /dev/null
+++ b/lib/tasks/data_migration.rake
@@ -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
\ No newline at end of file
diff --git a/lib/tasks/mid_site_sync.rake b/lib/tasks/mid_site_sync.rake
index 87979b666..69e935670 100644
--- a/lib/tasks/mid_site_sync.rake
+++ b/lib/tasks/mid_site_sync.rake
@@ -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
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb
index a41c27acf..8944f9bb9 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb
@@ -51,12 +51,12 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
object_auth
end
- def get_categorys(id = nil)
- @bulletin_categorys = []
- if(is_manager? || is_admin?)
- @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
- elsif is_sub_manager?
- @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
- end
- end
+ # def get_categorys(id = nil)
+ # @bulletin_categorys = []
+ # if(is_manager? || is_admin?)
+ # @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.all)
+ # elsif is_sub_manager?
+ # @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
+ # end
+ # end
end
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
index b1ce17186..56de21040 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
@@ -1,11 +1,11 @@
class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController
-
+ include OrbitControllerLib::DivisionForDisable
before_filter :for_app_manager,:except => [:index]
def index
- @bulletin_categorys = BulletinCategory.all
+ @bulletin_categorys = get_categories_for_index("BulletinCategory")
+ #TODO 需要做 manager ,admin 才可以 all. 其他 available就好
@bulletin_category = BulletinCategory.new(:display => 'List')
-
@url = panel_announcement_back_end_bulletin_categorys_path
respond_to do |format|
@@ -108,12 +108,19 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
# DELETE /bulletins/1.xml
def destroy
@bulletin_category = BulletinCategory.find(params[:id])
- @bulletin_category.destroy
+ @bulletin_category.disable = @bulletin_category.disable ? false : true
- respond_to do |format|
- format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) }
- # format.xml { head :ok }
- format.js
+ if @bulletin_category.save!
+ respond_to do |format|
+ flash[:notice] = t("bulletin_category.update_success")
+ # flash[:error] += @bulletin_category.disable ? t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false")
+ format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) }
+ # format.xml { head :ok }
+ format.js
+ end
+ else
+ flash[:error] = t("bulletin_category.update_failed")
+ format.html { render :action => "index" }
end
end
end
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 1dceb90e6..f6b7911d2 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
@@ -1,15 +1,20 @@
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
include AdminHelper
+ include OrbitControllerLib::DivisionForDisable
+
layout 'new_admin'
before_filter :authenticate_user!
+ before_filter :only => [ :new,:edit,:update] do |controller|
+ controller.get_categorys('BulletinCategory')
+ end
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
def index
# @bulletins = Bulletin.all
# @bulletins = Bulletin.desc("postdate desc")
- get_categorys(params[:bulletin_category_id])
+ get_categorys('BulletinCategory',params[:bulletin_category_id])
get_tags
@filter = params[:filter]
@@ -34,10 +39,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# @bulletins = Bulletin.search(params[:search], params[:category_id])
# @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]])
-
# @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10)
- @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("bulletin") : get_viewable("bulletin")
- @bulletin_categories = BulletinCategory.all
+ @bulletin_categories = get_categories_for_index("BulletinCategory")
+ @bulletin_category_ids = @bulletin_categories.collect{|t| t.id.to_s} + [nil]
+
+ @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("bulletin",:bulletin_category_id.in => @bulletin_category_ids) : get_viewable("bulletin",:bulletin_category_id.in => @bulletin_category_ids)
@bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path
@@ -76,22 +82,17 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# GET /bulletins/new
# GET /bulletins/new.xml
def new
- @bulletin = Bulletin.new
+ @bulletin = Bulletin.new(:postdate => DateTime.now)
@link_url = panel_announcement_back_end_bulletins_path
# @bulletin.bulletin_files.build
# @bulletin.bulletin_files.new
- if get_categorys.empty?
- flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
- redirect_to :action => :index
- else
get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bulletin }
- end
end
end
@@ -105,7 +106,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
- get_categorys
get_tags
end
end
@@ -137,7 +137,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
else
@bulletin = Bulletin.new(params[:bulletin])
- @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
+ @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
@@ -216,7 +216,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
-
if params[:bulletin_link]
@bulletin_link = BulletinLink.find(params[:id])
@@ -246,9 +245,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
else
@bulletin = Bulletin.find(params[:id])
- @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
-
- @bulletin.update_user_id = current_user.id
+
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
# if params[:bulletin][:image_del] == '1'
@@ -256,16 +253,22 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# @bulletin.image_del = nil
# params[:bulletin][:image_del] = nil
# end
-
+
+ delete_out_invalid_date_from_params
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin])
+ # if (@bulletin.deadline < @bulletin.postdate rescue nil)
+ # @bulletin.deadline = nil
+ # @bulletin.update_user_id = current_user.id
+ # @bulletin.save!
+ # end
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' }
format.xml { head :ok }
else
get_tags
- get_categorys
+
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
@@ -303,6 +306,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin = Bulletin.find(params[:id])
@type = params[:type]
@bulletin_categories = BulletinCategory.all
+ #TODO 需要做 manager ,admin 才可以 all. 其他 available就好
+
get_tags
end
@@ -316,15 +321,38 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
protected
- def get_categorys(id = nil)
- @bulletin_categorys = []
- #@unit_list_for_anc = UnitListForAnc.all
- if(is_manager? || is_admin?)
- @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
- elsif is_sub_manager?
- @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit')
+ def delete_out_invalid_date_from_params()
+ if(params[:bulletin]["deadline(1i)"].blank? or params[:bulletin]["deadline(2i)"].blank? or params[:bulletin]["deadline(3i)"].blank?)
+ params[:bulletin].delete("deadline(1i)")
+ params[:bulletin].delete("deadline(2i)")
+ params[:bulletin].delete("deadline(3i)")
+ params[:bulletin].delete("deadline(4i)")
+ params[:bulletin].delete("deadline(5i)")
end
end
+
+ # def get_categories_for_index(id = nil)
+ # @bulletin_categories = []
+ # if(is_manager? || is_admin?)
+ # @bulletin_categories = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
+ # elsif is_sub_manager?
+ # @bulletin_categories = BulletinCategory.all
+ # end
+ # @bulletin_categories
+ # end
+
+ # def get_categorys(id = nil)
+ # @bulletin_categorys = []
+ # if(is_manager? || is_admin?)
+ # @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
+ # elsif is_sub_manager?
+ # @bulletin_categorys = BulletinCategory.all.authed_for_user(current_user,'submit')
+ # end
+ # if @bulletin_categorys.empty? && params[:action] != "index"
+ # flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
+ # redirect_to :action => :index
+ # end
+ # end
def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
index 9fd97b9b9..238cbb6c9 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
@@ -43,7 +43,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
protected
def get_categorys
- @bulletin_categorys = BulletinCategory.excludes('disabled' => true)
+ @bulletin_categorys = BulletinCategory.all
end
end
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb
index 316a715b4..8a39862b6 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb
@@ -27,7 +27,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
end
def bulletins_and_web_links
- @tags = AnnouncementTag.any_in(key: ['students', 'alumni', 'employee', 'guest'])
+ @tags = AnnouncementTag.any_in(key: ['students', 'alumni', 'employee', 'guest']).asc(:order)
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
@@ -52,7 +52,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
protected
def get_categorys
- @bulletin_categorys = BulletinCategory.excludes('disabled' => true)
+ @bulletin_categorys = BulletinCategory.all
end
end
diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb
index c384bc8f7..91147c62a 100644
--- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb
+++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb
@@ -6,4 +6,35 @@ module Panel::Announcement::BackEnd::BulletinsHelper
by_bulletin and by_user
end
+ def show_delete_link(bulletin)
+ by_bulletin = (bulletin.create_user_id == current_user.id)
+ by_user = (is_manager? or is_admin?)
+ by_bulletin or by_user
+ end
+
+ def show_bulletin_title_at_index (bulletin)
+ if bulletin.is_checked?
+ link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''
+ else
+ bulletin.title[I18n.locale]
+ end
+ end
+
+ def file_picture_preview_setting(file_path)
+ res= ""
+ ext = File.extname(file_path)
+ unless file_path.nil?
+ case ext
+ when ".jpg",".jpeg",".png",".gif"
+ #res = '
'
+ #res << image_tag(file_path, {:title => t(:view)})
+ #res << '
'
+ #res.html_safe
+ {"data-content" => "#{image_tag file_path}" }
+ else
+ {"data-content" => t("sys.not_previewable") }
+ end
+ end
+ end
+
end
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/app/models/announcement_tag.rb b/vendor/built_in_modules/announcement/app/models/announcement_tag.rb
index 9cb29038b..8bc390ebd 100644
--- a/vendor/built_in_modules/announcement/app/models/announcement_tag.rb
+++ b/vendor/built_in_modules/announcement/app/models/announcement_tag.rb
@@ -1,7 +1,7 @@
class AnnouncementTag < Tag
has_and_belongs_to_many :bulletins
-
+ field :order,:default => 0
def get_visible_bulletins(sort = :name)
date_now = Time.now
diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb
index 0dae6a5f3..a9e31fa7f 100644
--- a/vendor/built_in_modules/announcement/app/models/bulletin.rb
+++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb
@@ -53,7 +53,7 @@ class Bulletin
validates_presence_of :title
- before_save :set_key, :update_status
+ before_save :set_key, :update_status,:check_deadline
after_save :save_bulletin_links
after_save :save_bulletin_files
@@ -166,6 +166,13 @@ end
protected
+ def check_deadline
+ if(!self.deadline.nil? and (self.deadline<= self.postdate ))
+ self.deadline = nil
+ end
+
+ end
+
def set_key
if title && title.new_record?
title.key = 'title'
diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb
index 74e5b6488..2f25c8882 100644
--- a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb
+++ b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb
@@ -4,7 +4,8 @@ class BulletinCategory
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
-
+ include OrbitCoreLib::ObjectDisable
+
ObjectAuthTitlesOptions = %W{submit_new fact_check}
AfterObjectAuthUrl = '/panel/announcement/back_end/bulletin_categorys'
# include Mongoid::MultiParameterAttributes
@@ -14,11 +15,14 @@ class BulletinCategory
field :key
field :display
-
+ field :disable,type: Boolean,:default => false
+
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
has_many :bulletins
+
+
def pp_object
i18n_variable[I18n.locale]
end
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb
index b5013698b..58a9a5f9b 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb
@@ -4,14 +4,13 @@
<%= bulletin_category.key %>
+ <% if is_admin?%>
+ - <%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %>
+ - <%= link_to show_toggle_archive_btn(bulletin_category) , panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true,:class=> "archive_toggle" %>
+ <% end %>
<%if is_manager? || is_admin? %>
- <%= show_anc_cate_permission_link(bulletin_category) %>
<% end %>
- <% if is_admin?%>
- - <%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %>
- - <%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>
- <% end %>
-
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb
index 882b13d22..e7f791906 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/destroy.js.erb
@@ -1 +1 @@
-$("#<%= dom_id @bulletin_category %>").remove();
\ No newline at end of file
+$("#<%= dom_id @bulletin_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@bulletin_category) %> ");
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
index 8f879e795..edff4d2d5 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
@@ -30,8 +30,7 @@
<%= bulletin.bulletin_category.i18n_variable[I18n.locale] rescue nil %> |
- <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%>
-
+ <%= show_bulletin_title_at_index bulletin%>
<% if (bulletin.create_user_id == current_user.id) || is_manager? %>
@@ -48,12 +47,12 @@
- <%= link_to t(:file), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %>
- <%#= debugger %>
- <%#= a=1 %>
-
<% end %>
- <%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>
+
<% end -%>
+ <% if show_delete_link(bulletin) %>
+ <%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>
+ <% end %>
<% if show_approval_link(bulletin) %>
<%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb
index c515dc656..73d088b74 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb
@@ -123,7 +123,7 @@
<%#= f.label :unit_list_for_anc%>
<%#= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
- <%= f.label :category %>
+ <%= f.label :category,t('announcement.bulletin.category')%>
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
@@ -141,23 +141,16 @@
">
- <%= f.label :title %>
+ <%= f.label :title ,t('announcement.bulletin.title')%>
<%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title' %>
<% end %>
+
- <%= f.label :subtitle %>
- <%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %>
- <%= I18nVariable.from_locale(locale) %>
- <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
- <% end %>
-
-
-
- <%= f.label :text %>
+ <%= f.label :text ,t('announcement.bulletin.text')%>
<%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
@@ -239,6 +232,7 @@
|
@@ -277,6 +271,8 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/jquery.imagesloaded.js" %>
<% end %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb
index 38ab1edbf..8aeab6c63 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb
@@ -4,7 +4,8 @@
<%= f.file_field :file %>
- <%= form_bulletin_file.file.file ? ( link_to t(:view), form_bulletin_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %>
+ <%#= form_bulletin_file.file.file ? ( link_to t(:view), form_bulletin_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %>
+ <%= form_bulletin_file.file.file ? ( link_to t(:view), form_bulletin_file.file.url, {:class => 'for_preview btn', :target => '_blank', :title => t(:view)}.merge(file_picture_preview_setting(form_bulletin_file.file.url)) ) : '' %>
@@ -62,6 +63,7 @@
<% else %>
<%= f.hidden_field :id %>
+ <%= hidden_field_tag :tr, (dom_id form_bulletin_file) %>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_link.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_link.html.erb
index cfd913588..af29e28c1 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_link.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_link.html.erb
@@ -39,6 +39,7 @@
<% else %>
<%= f.hidden_field :id %>
+ <%= hidden_field_tag :tr, (dom_id form_bulletin_link) %>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb
index 272110470..c15e45b12 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb
@@ -8,3 +8,7 @@
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
+<% content_for :page_specific_javascript do %>
+ <%= javascript_include_tag "bulletin_form" %>
+<% end %>
+
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb
index c64035a56..526dbeadc 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb
@@ -18,6 +18,12 @@