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 committed 2012-07-09 16:02:59 +08:00
commit 09d46f2f75
79 files changed
+683 -278

No files matched your search

+9 -2
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();
});
});
@@ -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();
});
});
@@ -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
@@ -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
+1 -1
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
+5 -3
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
+46 -35
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)
+1 -1
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
+4
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
+1 -1
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
+3 -2
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
+1 -1
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"
+3 -3
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
+4 -4
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
-6
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 %>
+1 -4
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 %>
+7 -2
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>
+2 -2
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'>