NCCU 上傳版本 0709

Merge branch 'nccu0621'

Conflicts:
	Gemfile
	config/resque.god
	vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
This commit is contained in:
Matthew K. Fu JuYuan 2012-07-09 16:02:59 +08:00
commit 09d46f2f75
79 changed files with 683 additions and 278 deletions

View File

@ -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"

View File

@ -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();
});
});

View File

@ -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();
});
});

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -24,12 +24,6 @@
</div>
</div>
<div class="form-actions clear">
<div class=" pull-left">
<label for="user_remember_me">
<%= f.check_box :remember_me, :style => "display: inline-block;" %>
<span style="display: inline-block;height: 10px;"><%= t(:remember_me) %></span>
</label>
</div>
<%= content_tag :button, t(:login), :type => :submit, :class => 'btn btn-primary pull-right' %>
</div>
<% end %>

View File

@ -94,10 +94,7 @@
</li>
<li>
<%= content_tag :button, t(:login), :type => :submit, :class => 'btn btn-primary' %>
<label class="remember" for="user_remember_me">
<%= f.check_box :remember_me %>
<span style="display: inline-block;height: 10px;"><%= t(:remember_me) %></span>
</label>
</li>
<li class="divider hide"><span><%= t(:or_lower) %></span></li>
<% end %>

View File

@ -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 -%>
<div class="content">
<% flash.each do |key, msg| %>
<%= content_tag :span, msg, :class => [key, "notice label label-warning"] %>
<% end%>
</div>

View File

@ -1,6 +1,6 @@
<div class="checkblock">
<div class="for_unit" style="display:none;"> <%= user.cache_dept[I18n.locale.to_s] %></div>
<%= 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 %>
<div class="for_unit" style="display:none;"> <%= user.cache_dept[I18n.locale.to_s] rescue ''%></div>
<%= 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 %>
<div class="check-icon">
</div>
<div class='member-avatar'>

View File

@ -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]

View File

@ -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

12
config/ldap.yml Normal file
View File

@ -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

View File

@ -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}"

View File

@ -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: "重新啓用"

View File

@ -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
end

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'})

View File

@ -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

View File

@ -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

View File

@ -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 = '<div class="for_preview" style="display:none;">'
#res << image_tag(file_path, {:title => t(:view)})
#res << '</div>'
#res.html_safe
{"data-content" => "#{image_tag file_path}" }
else
{"data-content" => t("sys.not_previewable") }
end
end
end
end

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -4,14 +4,13 @@
<%= bulletin_category.key %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if is_admin?%>
<li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li>
<li><%= 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" %></li>
<% end %>
<%if is_manager? || is_admin? %>
<li><%= show_anc_cate_permission_link(bulletin_category) %></li>
<% end %>
<% if is_admin?%>
<li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li>
<li><%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<% end %>
</ul>
</div>
</td>

View File

@ -1 +1 @@
$("#<%= dom_id @bulletin_category %>").remove();
$("#<%= dom_id @bulletin_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@bulletin_category) %> ");

View File

@ -30,8 +30,7 @@
</td>
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] rescue nil %></td>
<td>
<%= 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%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if (bulletin.create_user_id == current_user.id) || is_manager? %>
@ -48,12 +47,12 @@
<li><%= link_to t(:file), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<%#= debugger %>
<%#= a=1 %>
<% end %>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<% end -%>
<% if show_delete_link(bulletin) %>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<% end %>
<% if show_approval_link(bulletin) %>
<li><%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>

View File

@ -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" %>
<ul class="nav nav-tabs">
@ -141,23 +141,16 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= 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 %>
</div>
<div class="editor">
<%= 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 %>
</div>
<div class="editor">
<%= 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 @@
<div id='add_bulletin_file' class="info_input bulletin_files_block">
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i><%= t(:add) %></span></a>
<p><%= t("sys.limit_of_upload_file_size",:best_size => '3MB') %></p>
</div>
</td>
</tr>
@ -277,6 +271,8 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/jquery.imagesloaded.js" %>
<script>
$(document).ready(function() {
$('#add_bulletin_link a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g");
@ -289,5 +285,7 @@
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id));
});
$('.for_preview').popover({ html : true });
});
</script>
<% end %>

View File

@ -4,7 +4,8 @@
<div class="control-group">
<div class="controls">
<%= 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)) ) : '' %>
</div>
</div>
</td>
@ -62,6 +63,7 @@
<a class="delete"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id form_bulletin_file) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>

View File

@ -39,6 +39,7 @@
<a class="delete"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id form_bulletin_link) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>

View File

@ -8,3 +8,7 @@
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bulletin_form" %>
<% end %>

View File

@ -18,6 +18,12 @@
</div>
</div>
<div id="news_bulletin_file_qe">
<div id="modal-file" class="modal fade">
<%= render :partial => "bulletin_file_qe" %>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bulletin_form" %>
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>

View File

@ -3,10 +3,8 @@
<div class="info">
<div class="info1">
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
<% unit = User.find(@bulletin.create_user_id).sub_roles.collect{|t| t.key}.join(" ") rescue nil %>
<%= " | " if unit %>
<a href="" class="unit"><%= unit %></a>
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
<span><%= User.find(@bulletin.create_user_id).cache_dept[I18n.locale.to_s] rescue nil %></span>
</div>
</div>
<div class="news_image">

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -4,14 +4,13 @@
<%= news_bulletin_category.key %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if is_admin?%>
<li><%= link_to t('bulletin_category.edit'), edit_panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(news_bulletin_category), panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true,:class=>"archive_toggle" %></li>
<% end %>
<%if is_manager? || is_admin? %>
<li><%= show_news_cate_permission_link(news_bulletin_category) %></li>
<% end %>
<% if is_admin?%>
<li><%= link_to t('bulletin_category.edit'), edit_panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :remote => true %></li>
<li><%= link_to t('bulletin_category.delete'), panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<% end %>
</ul>
</div>
</td>

View File

@ -1 +1 @@
$("#<%= dom_id @news_bulletin_category %>").remove();
$("#<%= dom_id @news_bulletin_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@news_bulletin_category) %> ");

View File

@ -118,10 +118,10 @@
<div id="post-body">
<div id="post-body-content" class="clear">
<%= 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" %>
<ul class="nav nav-tabs">
@ -139,7 +139,7 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= f.label :title %>
<%= f.label :title, t('news.news_bulletin.title')%>
<%= f.fields_for :title, (@news_bulletin.new_record? ? @news_bulletin.build_title : @news_bulletin.title ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title' %>
@ -147,7 +147,7 @@
</div>
<div class="editor">
<%= f.label :subtitle %>
<%= f.label :subtitle, t('news.news_bulletin.subtitle') %>
<%= f.fields_for :subtitle, (@news_bulletin.new_record? ? @news_bulletin.build_subtitle : @news_bulletin.subtitle ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
@ -155,7 +155,7 @@
</div>
<div class="editor">
<%= f.label :text %>
<%= f.label :text, t('news.news_bulletin.text') %>
<%= f.fields_for :text, (@news_bulletin.new_record? ? @news_bulletin.build_text : @news_bulletin.text ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
@ -237,6 +237,8 @@
<div id='add_news_bulletin_file' class="info_input news_bulletin_files_block">
<%= hidden_field_tag 'news_bulletin_file_field_count', @news_bulletin.news_bulletin_files.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i><%= t(:add) %></span></a>
<p><%= t("sys.limit_of_upload_file_size",:best_size => '3MB') %></p>
</div>
</td>
</tr>
@ -249,10 +251,9 @@
<%= render :partial => 'form_news_bulletin_file', :object => news_bulletin_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
@ -275,17 +276,20 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/jquery.imagesloaded.js" %>
<script>
$('#add_news_bulletin_link a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_news_bulletin_links", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_news_bulletin_link', f, :news_bulletin_links) %>").replace(old_id, new_id));
});
$('#add_news_bulletin_file a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_news_bulletin_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_news_bulletin_file', f, :news_bulletin_files) %>").replace(old_id, new_id));
$(document).ready(function() {
$('#add_news_bulletin_link a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_news_bulletin_links", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_news_bulletin_link', f, :news_bulletin_links) %>").replace(old_id, new_id));
});
$('#add_news_bulletin_file a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_news_bulletin_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_news_bulletin_file', f, :news_bulletin_files) %>").replace(old_id, new_id));
});
$('.for_preview').popover({ html : true });
});
</script>
<% end %>

View File

@ -4,7 +4,7 @@
<div class="control-group">
<div class="controls">
<%= f.file_field :file %>
<%= form_news_bulletin_file.file.file ? ( link_to t(:view), form_news_bulletin_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %>
<%= form_news_bulletin_file.file.file ? ( link_to t(:view), form_news_bulletin_file.file.url, {:class => 'for_preview btn', :target => '_blank', :title => t(:view)}.merge(file_picture_preview_setting(form_news_bulletin_file.file.url)) ) : '' %>
</div>
</div>
</td>
@ -62,6 +62,7 @@
<a class="delete"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id form_news_bulletin_file) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>

View File

@ -39,6 +39,7 @@
<a class="delete"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id form_news_bulletin_link) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>

View File

@ -29,9 +29,7 @@
</div>
</td>
<td><%= news_bulletin.news_bulletin_category.i18n_variable[I18n.locale] rescue nil %></td>
<td>
<%= 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 ''%>
<td> <%= show_news_bulletin_title_at_index news_bulletin%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if (news_bulletin.create_user_id == current_user.id) || is_manager? %>
@ -52,6 +50,8 @@
<%#= a=1 %>
<% end %>
<% end %>
<% if news_show_delete_link(news_bulletin) %>
<li class="dropdown"><%= link_to t('news_bulletin.delete'), panel_news_back_end_news_bulletin_path(news_bulletin), :confirm => t('news.sure?'), :method => :delete, :remote => true %></li>
<% end %>
<% if news_show_approval_link(news_bulletin) %>

View File

@ -8,3 +8,6 @@
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "news_bulletin_form" %>
<% end %>

View File

@ -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

View File

@ -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: 管理

View File

@ -19,5 +19,6 @@
<%end -%>
</td>
<td><%= display_date_time(page_context.updated_at) %></td>
<td><%= User.find(page_context.create_user_id).name rescue ''%></td>
<td><%= User.find(page_context.create_user_id).name rescue '' %></td>
</tr>

View File

@ -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

View File

@ -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'})

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -6,8 +6,8 @@
<%if at_least_module_manager %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('web_link_category.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li>
<li><%= link_to t('web_link_category.delete'), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<li><%= link_to t('web_resource.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(web_link_category), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true ,:class=> "archive_toggle"%></li>
<li><%= show_web_link_permission_link web_link_category %></li>
</ul>
</div>

View File

@ -1 +1 @@
$("#<%= dom_id @web_link_category %>").remove();
$("#<%= dom_id @web_link_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@web_link_category) %> ");

View File

@ -53,7 +53,7 @@
<div id="post-body">
<div id="post-body-content" class="clear">
<%= 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 ]} %>
<ul class="nav nav-tabs">
@ -68,7 +68,7 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= f.label :name %>
<%= f.label :name ,t("web_resource.name")%>
<%= f.fields_for :name, (@web_link.new_record? ? @web_link.build_name : @web_link.name ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title' %>
@ -76,7 +76,7 @@
</div>
<div class="title">
<%= f.label :describe %>
<%= f.label :describe,t("web_resource.describe") %>
<%= f.fields_for :context, (@web_link.new_record? ? @web_link.build_context : @web_link.context ) do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%" %>
@ -90,7 +90,7 @@
</div>
<div class="title">
<%= f.label :url %>
<%= f.label :url,t("web_resource.url") %>
<%= f.text_field :url %>
</div>

View File

@ -25,8 +25,8 @@
<div class="quick-edit">
<ul class="nav nav-pills hide">
<%if at_least_module_manager || web_link.web_link_category.cur_user_is_sub_manager_of(:edit)%>
<li><%= link_to t('web_link.edit'), edit_panel_web_resource_back_end_web_link_path(web_link) %></li>
<li><%= link_to t('web_link.delete'), panel_web_resource_back_end_web_link_path(web_link), :confirm => t('sure?'), :method => :delete, :remote => true %></li>
<li><%= link_to t('edit'), edit_panel_web_resource_back_end_web_link_path(web_link) %></li>
<li><%= link_to t('delete'), panel_web_resource_back_end_web_link_path(web_link), :confirm => t('sure?'), :method => :delete, :remote => true %></li>
<% end -%>
</ul>
</div>

View File

@ -21,7 +21,13 @@ zh_tw:
web_resource:
list_lower: 列表
list_link: 鏈接列表
category: 分類
name: 名稱
describe: 描述
url: 路徑
edit: 編輯
delete: 刪除
cate_auth: 分類授權
# Chinese (Taiwan) translations for Ruby on Rails