diff --git a/Gemfile b/Gemfile index 22a4e0c18..b3461c3a9 100644 --- a/Gemfile +++ b/Gemfile @@ -29,11 +29,12 @@ gem 'resque-restriction' #gem 'rb-readline' gem 'ruby-debug19' gem 'rubyzip' -gem 'therubyracer' gem 'sinatra' gem 'sprockets' gem 'tinymce-rails' gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") +gem 'rb-readline' if RUBY_PLATFORM.downcase.include?("linux") + gem "impressionist", :require => "impressionist", :path => "vendor/impressionist" diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index cf2dfd69c..0240c6133 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -1,3 +1,6 @@ +<%#= encoding: utf-8 %> +$(document).ready(function(){ +//alert("Anc Loaded"); $('.bulletin_links_block a.delete').live('click', function(){ $(this).parents('.list_item').remove(); }); @@ -7,8 +10,10 @@ $('.bulletin_files_block a.delete').live('click', function(){ }); $(document).on('click', '.action a.remove_existing_record', function(){ - $(this).next('.should_destroy').attr('value', 1); - $("tr #" + $(this).prev().attr('value')).hide(); + if(confirm("<%= I18n.t('announcement.sure?')%>")){ + $(this).next('.should_destroy').attr('value', 1); + $("tr#" + $(this).prev().attr('value')).hide(); + } }); $(document).on('click', '.quick_edit_cancel', function(){ @@ -16,4 +21,6 @@ $(document).on('click', '.quick_edit_cancel', function(){ $('#' + tr).hide(); $("tr#bulletin_file_" + $(this).prev().attr('value')).hide(); $("tr#bulletin_link_" + $(this).prev().attr('value')).hide(); +}); + }); \ No newline at end of file diff --git a/app/assets/javascripts/news_bulletin_form.js b/app/assets/javascripts/news_bulletin_form.js.erb similarity index 68% rename from app/assets/javascripts/news_bulletin_form.js rename to app/assets/javascripts/news_bulletin_form.js.erb index 6f0f9ac56..e75e8d4f9 100644 --- a/app/assets/javascripts/news_bulletin_form.js +++ b/app/assets/javascripts/news_bulletin_form.js.erb @@ -1,3 +1,7 @@ +<%#= encoding: utf-8 %> +$(document).ready(function(){ +//alert("News Loaded"); + $('.news_bulletin_links_block a.delete').live('click', function(){ $(this).parents('.list_item').remove(); }); @@ -7,8 +11,10 @@ $('.news_bulletin_files_block a.delete').live('click', function(){ }); $(document).on('click', '.action a.remove_existing_record', function(){ - $(this).next('.should_destroy').attr('value', 1); - $("tr #" + $(this).prev().attr('value')).hide(); + if(confirm("<%= I18n.t('news.sure?')%>")){ + $(this).next('.should_destroy').attr('value', 1); + $("tr#" + $(this).prev().attr('value')).hide(); + } }); $(document).on('click', '.quick_edit_cancel', function(){ @@ -16,4 +22,5 @@ $(document).on('click', '.quick_edit_cancel', function(){ $('#' + tr).hide(); $("tr#news_bulletin_file_" + $(this).prev().attr('value')).hide(); $("tr#news_bulletin_link_" + $(this).prev().attr('value')).hide(); +}); }); \ No newline at end of file diff --git a/app/controllers/admin/module_apps_new_interface_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb index f8770ab32..863af5609 100644 --- a/app/controllers/admin/module_apps_new_interface_controller.rb +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -56,7 +56,7 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController def get_categorys(id = nil) @bulletin_categorys = [] if(is_manager? || is_admin?) - @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + @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 diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb index 42e82b479..31c5e9007 100644 --- a/app/controllers/admin/object_auths_new_interface_controller.rb +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -49,7 +49,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController # def get_categorys(id = nil) # @bulletin_categorys = [] # if(is_manager? || is_admin?) - # @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + # @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 diff --git a/app/controllers/gridfs_controller.rb b/app/controllers/gridfs_controller.rb index 4be7ec17b..b7f926b14 100644 --- a/app/controllers/gridfs_controller.rb +++ b/app/controllers/gridfs_controller.rb @@ -3,7 +3,7 @@ require 'mongo' class GridfsController < ActionController::Metal def serve - gridfs_path = env["PATH_INFO"].gsub("/gridfs/", "").force_encoding("UTF-8") + gridfs_path = (params[:path]+'.'+params[:format]).gsub("/gridfs/", "").force_encoding("UTF-8") begin gridfs_file = Mongo::GridFileSystem.new(Mongoid.database).open(gridfs_path, 'r') self.response_body = gridfs_file.read diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 28f99fa20..feefc98e6 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -154,15 +154,17 @@ class OrbitBackendController< ApplicationController end - def get_viewable(object_class) - objects = get_objects(object_class).order_by(:created_at, :desc) + def get_viewable(object_class, query=nil) + objects = get_objects(object_class,query).order_by(:created_at, :desc) Kaminari.paginate_array(objects).page(params[:page]).per(10) end def get_objects(object_class, query=nil) object_class = object_class.classify.constantize + # debugger + # a=1 if query - objects = object_class.all.where(query) + objects = object_class.where(query) else objects = object_class.all end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index a6925aa46..748c225c7 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,8 +1,6 @@ class SessionsController < Devise::SessionsController prepend_before_filter :require_no_authentication, :only => [ :new, :create ] include Devise::Controllers::InternalHelpers - MiddleSiteConnection.establish - NccuLdapConnection.establish # POST /resource/sign_in def create @@ -12,42 +10,55 @@ class SessionsController < Devise::SessionsController login_uid = params[:user][:nccu_ldap_uid] result = false ldap_filter = "(uid=#{login_uid})" - if $nccu_ldap_connection.bind - logger.info "=LDAP Binded password ok..." - result =check_auth_with_ldap(login_uid,login_password) - if result #&& login_password!='' - logger.info "==LDAP password passed..." - nccu_id = get_nccu_id_from_mid_site(login_uid) - resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id })) - # resource = env['warden'].authenticate!(:check_nccu_ldap) - # resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") - set_flash_message(:notice, :signed_in) if is_navigational_format? - if (resource.nil? || nccu_id.nil?) - logger.error "===LDAP passed local block... resource:#{resource.inspect}\n nccu_id:#{nccu_id} \t login_uid:#{login_uid}" - flash[:notice] = t('devise.failure.ldap_pass_but_account_not_in_orbit') - render :action => "new" - else - logger.info "===ALL passed" - resource_name = resource._type.downcase - sign_in(resource_name, resource) - respond_with resource, :location => redirect_location(resource_name, resource) - end - elsif resource = User.first(conditions:{email: login_uid}) + if /@rulingcom.com$/.match(login_uid).nil? + MiddleSiteConnection.establish + NccuLdapConnection.establish - resource_name = resource._type.downcase - sign_in(resource_name, resource) - respond_with resource, :location => redirect_location(resource_name, resource) + if ($nccu_ldap_connection.bind rescue false) + logger.info "=LDAP Binded password ok..." + result =check_auth_with_ldap(login_uid,login_password) + if result && login_password!='' + logger.info "==LDAP password passed..." + nccu_id = get_nccu_id_from_mid_site(login_uid) + resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id })) + # resource = env['warden'].authenticate!(:check_nccu_ldap) + # resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") + set_flash_message(:notice, :signed_in) if is_navigational_format? + if (resource.nil? || nccu_id.nil?) + logger.error "===LDAP passed local block... resource:#{resource.inspect}\n nccu_id:#{nccu_id} \t login_uid:#{login_uid}" + flash[:notice] = t('devise.failure.ldap_pass_but_account_not_in_orbit') + render :action => "new" + else + logger.info "===ALL passed" + resource_name = resource._type.downcase + sign_in(resource_name, resource) + respond_with resource, :location => redirect_location(resource_name, resource) + end + else + logger.error "==password LDAP fail..." + flash[:notice] = t('devise.failure.ldap_invalid') + render :action => "new" + end else - logger.error "==password LDAP fail..." - flash[:notice] = t('devise.failure.ldap_invalid') - render :action => "new" + logger.error "=LDAP fail..." + flash[:notice] = t('devise.failure.ldap_connection_failed') + render :action => "new" end - else - logger.error "=LDAP fail..." - flash[:notice] = t('devise.failure.ldap_connection_failed') - render :action => "new" - end - logger.info "=======End Debugging======" + else #if rulingcom account + logger.info "=======Rulingcom account======" + resource = User.first(conditions:{email: login_uid}) + if resource.valid_password?(login_password) + resource_name = resource._type.downcase + sign_in(resource_name, resource) + respond_with resource, :location => redirect_location(resource_name, resource) + else + logger.error "==password Local fail..." + flash[:notice] = t('devise.failure.invalid') + render :action => "new" + end + end + logger.info "=======End Debugging======" + end private def check_auth_with_ldap(login_uid,login_password) diff --git a/app/helpers/admin/web_link_helper.rb b/app/helpers/admin/web_link_helper.rb index 813bc48c5..0498f31b0 100644 --- a/app/helpers/admin/web_link_helper.rb +++ b/app/helpers/admin/web_link_helper.rb @@ -6,6 +6,6 @@ module Admin::WebLinkHelper web_link.object_auths.new(title: type ).save oa = web_link.get_object_auth_by_title(type) end - link_to t('admin.web_link.cate_auth'),admin_object_auth_ob_auth_path(oa) + link_to t('web_resource.cate_auth'),admin_object_auth_ob_auth_path(oa) end end \ No newline at end of file diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index 5d47e414a..e2865b9f3 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -42,4 +42,8 @@ module OrbitBackendHelper end end + def show_toggle_archive_btn(object) + object.disable ? t("object_disable.change_to_false") : t("object_disable.change_to_true") + end + end \ No newline at end of file diff --git a/app/jobs/nccu_calendar.rb b/app/jobs/nccu_calendar.rb index e06766273..8756029d1 100644 --- a/app/jobs/nccu_calendar.rb +++ b/app/jobs/nccu_calendar.rb @@ -16,6 +16,6 @@ end # FileUtils.mv(temp_file, File.join(Rails.root, 'public/static', 'nccu_calendar.xml')) - puts "NccuCalendar Synced4" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]NccuCalendar Synced" end end diff --git a/app/jobs/sync_db.rb b/app/jobs/sync_db.rb index f6e734cfc..9c92e816d 100644 --- a/app/jobs/sync_db.rb +++ b/app/jobs/sync_db.rb @@ -3,6 +3,7 @@ class SyncDb @queue = :high def self.perform() + puts "[ #{DateTime.now.strftime("%Y %D %H:%M") }]\t SyncDb Starting" self.start_sync self.set_admin end @@ -12,13 +13,13 @@ class SyncDb args = [] %x[rake #{task} --trace >> #{Rails.root}/log/rake.log] User.all.each{|ur| ur.create_dept_cache} - puts "SyncDb Synced" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]\tSyncDb Synced" end def self.set_admin task = 'mid_site:install_admin' args = [] %x[rake #{task} --trace >> #{Rails.root}/log/rake.log] - puts "Admin done" + puts "[#{ DateTime.now.strftime("%Y %D %H:%M")}]\tAdmin done" end end diff --git a/app/models/app_manager.rb b/app/models/app_manager.rb index 46cbbb913..0d81a0ec2 100644 --- a/app/models/app_manager.rb +++ b/app/models/app_manager.rb @@ -1,7 +1,7 @@ class AppManager include Mongoid::Document include Mongoid::Timestamps - + belongs_to :user belongs_to :managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :managers,:foreign_key => "user_id" diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 7ad4ac1dd..9708316f9 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -4,7 +4,7 @@ class ModuleApp include OrbitCoreLib::ObjectTokenUnility field :key - field :title + field :title field :version field :organization field :author @@ -16,8 +16,8 @@ class ModuleApp field :app_pages ,type: Array field :widgets ,type: Array - has_many :managers,as: :managing_app ,:class_name => "AppManager" #,:dependent => :destroy,:foreign_key => "managing_app_id",:inverse_of => :managing_app - has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager"#, :dependent => :destroy,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app + has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app + has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app has_many :tags has_many :page_parts diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 7c1e4c63d..46dc10400 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -17,10 +17,10 @@ class User has_many :attribute_values, :autosave => true, :dependent => :destroy has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists - has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth" - has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth" + has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth", :dependent => :destroy + has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth", :dependent => :destroy - has_many :managing_apps,:class_name => "AppManager" + has_many :managing_apps,:class_name => "AppManager", :dependent => :destroy belongs_to :role has_and_belongs_to_many :sub_roles @@ -72,7 +72,7 @@ class User if info first_name = get_attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil last_name = get_attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil - return "#{first_name} #{last_name}" + return "#{last_name} #{first_name}" else return nil end diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 4eee59d88..26ca75993 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -24,12 +24,6 @@
-
- -
<%= content_tag :button, t(:login), :type => :submit, :class => 'btn btn-primary pull-right' %>
<% end %> diff --git a/app/views/layouts/_orbit_bar.html.erb b/app/views/layouts/_orbit_bar.html.erb index a661dd663..4b74ab280 100644 --- a/app/views/layouts/_orbit_bar.html.erb +++ b/app/views/layouts/_orbit_bar.html.erb @@ -94,10 +94,7 @@
  • <%= content_tag :button, t(:login), :type => :submit, :class => 'btn btn-primary' %> - +
  • <%= t(:or_lower) %>
  • <% end %> diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 73b5191ae..c0507e671 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -12,7 +12,7 @@ <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class =>( active_for_action('bulletin_categorys', 'index') || active_for_ob_auths_object("BulletinCategory") ) %> <%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('/panel/announcement/back_end/tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue nil) %> + <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue true) %> <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "Announcement"}))), :class => active_for_app_auth('Announcement') if (is_admin? rescue nil) %> <% end -%> @@ -26,7 +26,7 @@ <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_news_back_end_news_bulletin_path), :class => active_for_action('news_bulletins', 'new') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_news_back_end_news_bulletin_categorys_path), :class => active_for_action('news_bulletin_categorys', 'index') || active_for_ob_auths_object("NewsBulletinCategory") %> <%= content_tag :li, link_to(t('announcement.tags'), panel_news_back_end_tags_path), :class => active_for_action('/panel/news/back_end/tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %> + <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue true) %> <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "news"}))), :class => active_for_app_auth('news') if (is_admin? rescue nil) %> <% end -%> @@ -75,3 +75,8 @@ <%#= content_tag :li, link_to(t('admin.tags'), admin_asset_tags_path), :class => active_for_action('/admin/asset_tags', 'index') %> <%# end -%> <%# end -%> +
    + <% flash.each do |key, msg| %> + <%= content_tag :span, msg, :class => [key, "notice label label-warning"] %> + <% end%> +
    \ No newline at end of file diff --git a/app/views/shared/_privilege_user.html.erb b/app/views/shared/_privilege_user.html.erb index 9d49be356..ba68996f4 100644 --- a/app/views/shared/_privilege_user.html.erb +++ b/app/views/shared/_privilege_user.html.erb @@ -1,6 +1,6 @@
    - - <%= 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.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 %>
    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%>
    - <%#= debugger %> - <%#= a=1 %> - <% end %> - + <% end -%> + <% if show_delete_link(bulletin) %> + + <% 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" %>
    +
    + +
    + <% content_for :page_specific_javascript do %> <%= javascript_include_tag "bulletin_form" %> <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index 24c61043c..e14589b2d 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -3,10 +3,8 @@
    <%= dislpay_view_count(@bulletin) %> - <%= display_date_time(@bulletin.postdate) %> - <% unit = User.find(@bulletin.create_user_id).sub_roles.collect{|t| t.key}.join(" ") rescue nil %> - <%= " | " if unit %> - <%= unit %> + <%= display_date_time(@bulletin.postdate) %> + <%= User.find(@bulletin.create_user_id).cache_dept[I18n.locale.to_s] rescue nil %>
    diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 4d4d426d6..3d941335e 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -85,7 +85,14 @@ en: cate_auth: Category Authorization submit_approval: Submit approval tag_cloud: Tag cloud - + + bulletin_category: + edit: Edit + delete: Delete + update_success: Bulletin Category Updated + update_failed: Bulletin Category Failed + disable_change_to_false: Toggle to archive + disable_change_to_true: Put back from archive # admin: # action: Action # add_language: Add language diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index 4fb22bb9e..55931284c 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -49,6 +49,7 @@ zh_tw: bulletins: 公告訊息 related_links: 相關連結 bulletin: + text: 內文 category: 分類 submit_user_list: 張貼人 list_lower: 列表 @@ -78,6 +79,7 @@ zh_tw: fact_check: 公告審核 delete: 刪除 edit: 編輯 + # action: 行動 # add_language: 新增語言 # admin: 管理 @@ -177,6 +179,8 @@ zh_tw: bulletin_category: edit: 修改 delete: 刪除 + update_success: 分類更新成功 + update_failed: 分類更新失敗 # Chinese (Taiwan) translations for Ruby on Rails # by tsechingho (http://github.com/tsechingho) diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb index 0f10fe91f..f3f6cc226 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb @@ -4,11 +4,11 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController include AdminHelper def preview_and_approve - @news_bulletin = NewsBulletin.find params[:news_category][:id] + @news_bulletin = NewsBulletin.find params[:news_bulletin_id] end def approve - + end def setting @@ -54,7 +54,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController def get_categorys(id = nil) @news_bulletin_categorys = [] if(is_manager? || is_admin?) - @news_bulletin_categorys = (id ? NewsBulletinCategory.find(id).to_a : NewsBulletinCategory.excludes('disabled' => true)) + @news_bulletin_categorys = (id ? NewsBulletinCategory.find(id).to_a : NewsBulletinCategory.all) elsif is_sub_manager? @news_bulletin_categorys = NewsBulletinCategory.authed_for_user(current_user,'submit_new') end diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletin_categorys_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletin_categorys_controller.rb index e3ac7476e..1fb743f97 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletin_categorys_controller.rb @@ -1,10 +1,12 @@ class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendController - + include OrbitControllerLib::DivisionForDisable before_filter :for_app_manager,:except => [:index] def index - @news_bulletin_categorys = NewsBulletinCategory.all + @news_bulletin_categorys = get_categories_for_index("NewsBulletinCategory") + #TODO 需要做 manager ,admin 才可以 all. 其他 available就好 + @news_bulletin_category = NewsBulletinCategory.new(:display => 'List') @url = panel_news_back_end_news_bulletin_categorys_path @@ -109,12 +111,20 @@ class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendContro # DELETE /news_bulletins/1.xml def destroy @news_bulletin_category = NewsBulletinCategory.find(params[:id]) - @news_bulletin_category.destroy + @news_bulletin_category.disable = @news_bulletin_category.disable ? false : true + + if @news_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_news_bulletin_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("bulletin_category.update_failed") + format.html { render :action => "index" } - respond_to do |format| - format.html { redirect_to(panel_news_back_end_news_bulletin_categorys_url) } - # format.xml { head :ok } - format.js end end end diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb index b8fa7cc89..d77927e51 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb @@ -1,15 +1,20 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController - + include OrbitControllerLib::DivisionForDisable before_filter :authenticate_user! # 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_news_bulletins] + before_filter :only => [ :new,:edit,:update] do |controller| + controller.get_categorys('NewsBulletinCategory') + controller.get_unit_list + end + def index # @news_bulletins = NewsBulletin.all # @news_bulletins = NewsBulletin.desc("postdate desc") - get_categorys(params[:news_bulletin_category_id]) + get_categorys("NewsBulletinCategory",params[:news_bulletin_category_id]) get_tags @filter = params[:filter] @@ -36,8 +41,12 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController # @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_news_bulletins : NewsBulletin.all.page(params[:page]).per(10) - @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("news_bulletin") : get_viewable("news_bulletin") - @news_bulletin_categories = NewsBulletinCategory.all + + @news_bulletin_categories = get_categories_for_index("NewsBulletinCategory") + @news_bulletin_category_ids = @news_bulletin_categories.collect{|t| t.id.to_s} + [nil] + + + @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) : get_viewable("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) @news_bulletin_link = NewsBulletinLink.new @link_url = panel_news_back_end_news_bulletins_path @@ -76,21 +85,18 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController # GET /news_bulletins/new # GET /news_bulletins/new.xml def new + @news_bulletin = NewsBulletin.new @link_url = panel_news_back_end_news_bulletins_path # @news_bulletin.news_bulletin_files.build # @news_bulletin.news_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 => @news_bulletin } - end end end @@ -104,7 +110,6 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController @link_url = panel_news_back_end_news_bulletin_path(@news_bulletin) - get_categorys get_tags end end @@ -264,7 +269,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController format.xml { head :ok } else get_tags - get_categorys + format.html { render :action => "edit" } format.xml { render :xml => @news_bulletin.errors, :status => :unprocessable_entity } end @@ -303,6 +308,8 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController @news_bulletin = NewsBulletin.find(params[:id]) @type = params[:type] @news_bulletin_categories = NewsBulletinCategory.all + #TODO 需要做 manager ,admin 才可以 all. 其他 available就好 + get_tags end @@ -316,14 +323,31 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController protected - def get_categorys(id = nil) - @news_bulletin_categorys = [] - @unit_list_for_anc = UnitListForAnc.all - if(is_manager? || is_admin?) - @news_bulletin_categorys = (id ? NewsBulletinCategory.find(id).to_a : NewsBulletinCategory.excludes('disabled' => true)) - elsif is_sub_manager? - @news_bulletin_categorys = NewsBulletinCategory.authed_for_user(current_user,'submit') - end + # def get_categories_for_index(id = nil) + # @news_bulletin_categories = [] + # if(is_manager? || is_admin?) + # @news_bulletin_categories = (id ? NewsBulletinCategory.admin_manager_all.find(id).to_a : NewsBulletinCategory.admin_manager_all) + # elsif is_sub_manager? + # @news_bulletin_categories = NewsBulletinCategory.all + # end + # @news_bulletin_categories + # end + + # def get_categorys(id = nil) + # @news_bulletin_categorys = [] + # @unit_list_for_anc = UnitListForAnc.all + # if(is_manager? || is_admin?) + # @news_bulletin_categorys = (id ? NewsBulletinCategory.admin_manager_all.find(id).to_a : NewsBulletinCategory.admin_manager_all) + # elsif is_sub_manager? + # @news_bulletin_categorys = NewsBulletinCategory.all.authed_for_user(current_user,'submit') + # end + # if @news_bulletin_categorys.empty? && params[:action] != "index" + # flash[:alert] = t("news.error.no_avilb_cate_for_posting") + # redirect_to :action => :index + # end + # end + def get_unit_list + @unit_list_for_anc = UnitListForAnc.all end def get_tags diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb index 0b757d065..177773d17 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb @@ -62,7 +62,7 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController protected def get_categorys - @news_bulletin_categorys = NewsBulletinCategory.excludes('disabled' => true) + @news_bulletin_categorys = NewsBulletinCategory.all end end diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb index d31188576..817fc7bd6 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb @@ -65,7 +65,7 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController protected def get_categorys - @news_bulletin_categorys = NewsBulletinCategory.excludes('disabled' => true) + @news_bulletin_categorys = NewsBulletinCategory.all end end diff --git a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb index 8bf47a3d7..d448b5ffb 100644 --- a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb +++ b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb @@ -6,4 +6,18 @@ module Panel::News::BackEnd::NewsBulletinsHelper by_news_bulletin and by_user end + def news_show_delete_link(news_bulletin) + by_news_bulletin = (news_bulletin.create_user_id == current_user.id) + by_user = (is_manager? or is_admin?) + by_news_bulletin or by_user + end + + def show_news_bulletin_title_at_index (news_bulletin) + if news_bulletin.is_checked? + link_to news_bulletin.title[I18n.locale], panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id) rescue '' + else + news_bulletin.title[I18n.locale] + end + end + end \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/models/news_bulletin_category.rb b/vendor/built_in_modules/news/app/models/news_bulletin_category.rb index a9997b995..79443f825 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin_category.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin_category.rb @@ -4,7 +4,8 @@ class NewsBulletinCategory include Mongoid::Document include Mongoid::Timestamps include OrbitCoreLib::ObjectAuthable - + include OrbitCoreLib::ObjectDisable + ObjectAuthTitlesOptions = %W{submit_new fact_check} AfterObjectAuthUrl = '/panel/news/back_end/news_bulletin_categorys' # include Mongoid::MultiParameterAttributes @@ -16,7 +17,6 @@ class NewsBulletinCategory field :display has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy - has_many :news_bulletins def pp_object diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/_news_bulletin_category.html.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/_news_bulletin_category.html.erb index 94a4e851f..4c231c31a 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/_news_bulletin_category.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/_news_bulletin_category.html.erb @@ -4,14 +4,13 @@ <%= news_bulletin_category.key %>
    diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/destroy.js.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/destroy.js.erb index 0ffa06b1d..e2acc583a 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/destroy.js.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletin_categorys/destroy.js.erb @@ -1 +1 @@ -$("#<%= dom_id @news_bulletin_category %>").remove(); \ No newline at end of file +$("#<%= dom_id @news_bulletin_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@news_bulletin_category) %> "); \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb index eb2a2d95f..f3d1753b8 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb @@ -118,10 +118,10 @@
    - <%= 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 :unit_list_for_anc,t('news.news_bulletin.unit_name')%> + <%= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title[I18n.locale], t.id ]}, {:prompt => t("news.news_bulletin.ut_prompt")}, :class => "input-medium" %> - <%= f.label :category %> + <%= f.label :category,t('news.news_bulletin.category') %> <%= f.select :news_bulletin_category_id, @news_bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
    <%= news_bulletin.news_bulletin_category.i18n_variable[I18n.locale] rescue nil %> - - <%= link_to news_bulletin.title[I18n.locale], panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id) rescue ''%> - + <%= show_news_bulletin_title_at_index news_bulletin%>
    +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "news_bulletin_form" %> +<% end %> diff --git a/vendor/built_in_modules/news/config/locales/en.yml b/vendor/built_in_modules/news/config/locales/en.yml index 37f06ea43..94f3f5562 100644 --- a/vendor/built_in_modules/news/config/locales/en.yml +++ b/vendor/built_in_modules/news/config/locales/en.yml @@ -65,6 +65,7 @@ en: related_links: Related Links news: News news_bulletin: + ut_prompt: Please select UT category: Category list_lower: " list" title: Title diff --git a/vendor/built_in_modules/news/config/locales/zh_tw.yml b/vendor/built_in_modules/news/config/locales/zh_tw.yml index d52554c20..9d0030d2c 100644 --- a/vendor/built_in_modules/news/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/news/config/locales/zh_tw.yml @@ -47,9 +47,13 @@ zh_tw: related_links: 相關連結 news: 新聞 news_bulletin: + ut_prompt: 請選擇單位 category: 分類 list_lower: 列表 title: 標題 + subtitle: 副標題 + text: 內文 + unit_name: 發佈單位 postdate: 張貼日期 approval: 新聞審核 approval_setting: 審核設定 @@ -71,6 +75,10 @@ zh_tw: fact_check: 新聞審核 delete: 刪除 edit: 編輯 + update_success: 分類更新成功 + update_failed: 分類更新失敗 + + # action: 行動 # add_language: 新增語言 # admin: 管理 diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb index e11122f31..d1114a4a1 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb @@ -19,5 +19,6 @@ <%end -%> <%= display_date_time(page_context.updated_at) %> - <%= User.find(page_context.create_user_id).name rescue ''%> + + <%= User.find(page_context.create_user_id).name rescue '' %> \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb index a7d270a5a..8160fd892 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb @@ -1,8 +1,9 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendController before_filter :for_app_manager,:except => [:index] + include OrbitControllerLib::DivisionForDisable def index - @web_link_categorys = WebLinkCategory.all + @web_link_categorys = get_categories_for_index("WebLinkCategory") @web_link_category = WebLinkCategory.new(:display => 'List') @url = panel_web_resource_back_end_web_link_categorys_path @@ -86,12 +87,18 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendCont # DELETE /web_links/1.xml def destroy @web_link_category = WebLinkCategory.find(params[:id]) - @web_link_category.destroy + @web_link_category.disable = @web_link_category.disable ? false : true - respond_to do |format| - format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url) } - # format.xml { head :ok } - format.js + if @web_link_category.save! + respond_to do |format| + format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("web_link_category.update_failed") + format.html { render :action => "index" } end + end end diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb index af557bcb4..8189a05e1 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -1,12 +1,12 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController + include OrbitControllerLib::DivisionForDisable before_filter :authenticate_user! # before_filter :for_app_manager,:except => [:index,:show] before_filter :for_app_sub_manager,:except => [:index] def index - get_categorys(params[:web_link_category_id]) - + get_categorys("WebLinkCategory",params[:web_link_category_id]) @filter = params[:filter] new_filter = params[:new_filter] @@ -23,11 +23,14 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController elsif new_filter @filter = {new_filter[:type] => [new_filter[:id].to_s]} end + @web_link_categories = get_categories_for_index("WebLinkCategory") + @web_link_category_ids = @web_link_categories.collect{|t| t.id.to_s} + [nil] # @web_links = WebLink.search(params[:category_id]) - @web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10) - - get_tags + #@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10) + @web_links = (params[:sort] || @filter) ? get_sorted_and_filtered("web_link",:web_link_category_id.in => @web_link_category_ids) : get_viewable("web_link",:web_link_category_id.in => @web_link_category_ids) + + get_tags respond_to do |format| format.html # index.html.erb @@ -51,6 +54,7 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController # GET /web_links/new # GET /web_links/new.xml def new + @web_link = WebLink.new get_categorys @@ -131,17 +135,31 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController end protected - - def get_categorys(id = nil) - @web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true)) + - @web_link_categorys = [] - if(is_manager? || is_admin?) - @web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true)) - elsif is_sub_manager? - @web_link_categorys = WebLinkCategory.authed_for_user(current_user,'edit') - end - end + # def get_index_categories(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 + # end + # @bulletin_categorys + # end + + + # def get_categorys(id = nil) + # @web_link_categorys = [] + # if(is_manager? || is_admin?) + # @web_link_categorys = (id ? WebLinkCategory.admin_manager_all.find(id).to_a : WebLinkCategory.admin_manager_all)) + # elsif is_sub_manager? + # @web_link_categorys = WebLinkCategory.all.authed_for_user(current_user,'edit') + # end + # if @web_link_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 => 'web_resource'}) diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb index e605c7686..a254c9710 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb @@ -26,7 +26,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController protected def get_categorys - @web_link_categorys = WebLinkCategory.excludes('disabled' => true) + @web_link_categorys = WebLinkCategory.all end end diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb index 42419db26..fcb0cb1b3 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb @@ -47,7 +47,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController protected def get_categorys - @web_link_categorys = WebLinkCategory.excludes('disabled' => true) + @web_link_categorys = WebLinkCategory.all end def get_tags diff --git a/vendor/built_in_modules/web_resource/app/models/web_link_category.rb b/vendor/built_in_modules/web_resource/app/models/web_link_category.rb index f9ef5989b..53a10a1a2 100644 --- a/vendor/built_in_modules/web_resource/app/models/web_link_category.rb +++ b/vendor/built_in_modules/web_resource/app/models/web_link_category.rb @@ -4,7 +4,7 @@ class WebLinkCategory include Mongoid::Document include Mongoid::Timestamps include OrbitCoreLib::ObjectAuthable - + include OrbitCoreLib::ObjectDisable # include Mongoid::MultiParameterAttributes AfterObjectAuthUrl = '/panel/page_content/back_end/page_contexts' APP_NAME = 'web_resource' diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb index b17e634b1..8d018df44 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb @@ -6,8 +6,8 @@ <%if at_least_module_manager %>
    diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb index bea996335..fc1ed1421 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb @@ -1 +1 @@ -$("#<%= dom_id @web_link_category %>").remove(); \ No newline at end of file +$("#<%= dom_id @web_link_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@web_link_category) %> "); \ No newline at end of file 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 03d11db1c..60574b947 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 @@ -53,7 +53,7 @@
    - <%= f.label :category %> + <%= f.label :category ,t("web_resource.category")%> <%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %>