Changes on nccu

This commit is contained in:
Matt 2012-05-18 15:20:45 +08:00
parent 2c16284f73
commit 6a022c90da
15 changed files with 89 additions and 22 deletions

View File

@ -53,11 +53,11 @@
display:inline-block; display:inline-block;
margin-right: 5px; margin-right: 5px;
opacity: 0.8; opacity: 0.8;
filter: alpha(opacity:80); filter: alpha(opacity=80);
} }
.action:hover { .action:hover {
opacity: 1; opacity: 1;
filter: alpha(opacity:80); filter: alpha(opacity=80);
cursor: pointer; cursor: pointer;
} }
.select-role { .select-role {

View File

@ -30,7 +30,7 @@ class Admin::DashboardsController < ApplicationController
module_app_class = module_app.classify.constantize module_app_class = module_app.classify.constantize
objects = module_app_class.order_by(:updated_at, :desc).limit(10) objects = module_app_class.order_by(:updated_at, :desc).limit(10)
objects.each do |object| objects.each do |object|
a.merge!(object => object.updated_at) a.merge!(object => object.updated_at) unless (object.archived rescue nil)
end end
end end
sorted_objects = a.sort {|a,b| b[1]<=>a[1]} sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
@ -43,7 +43,7 @@ class Admin::DashboardsController < ApplicationController
module_app_class = module_app.classify.constantize module_app_class = module_app.classify.constantize
objects = module_app_class.order_by(:view_count, :desc).limit(10) objects = module_app_class.order_by(:view_count, :desc).limit(10)
objects.each do |object| objects.each do |object|
a.merge!(object => object.view_count) if object.view_count > 0 a.merge!(object => object.view_count) if object.view_count > 0 && (!object.archived rescue true)
end end
end end
sorted_objects = a.sort {|a,b| b[1]<=>a[1]} sorted_objects = a.sort {|a,b| b[1]<=>a[1]}

View File

@ -39,7 +39,7 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController
def update_setting_by_params def update_setting_by_params
user_sat = [] user_sat = []
ma = ModuleApp.find params[:module_app][:id] ma = ModuleApp.find params[:module_app][:id]
user_sat = User.find params[:users].keys if params.has_key? :users user_sat += User.find params[:users].keys if params.has_key?('users')
users_to_new = user_sat - ma.managing_users users_to_new = user_sat - ma.managing_users
users_to_remove = ma.managing_users - user_sat users_to_remove = ma.managing_users - user_sat

View File

@ -43,9 +43,59 @@ class ApplicationController < ActionController::Base
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil @parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
end end
def auth_failed_in_backend
#redirect_to admin_dashboards_url
redirect_to root_path
end
# Check if the current_user is admin # Check if the current_user is admin
def is_admin? def is_admin?
redirect_to root_url unless current_user.admin? current_user.admin? ? true : auth_failed_in_backend
end
def is_manager?
@module_app.managing_users.include?(current_user) || is_admin?
end
def for_admin_only
if is_admin?
true
else
flash[:error] = t("admin.access.denied.not_admin")
auth_failed_in_backend
end
end
def for_app_manager
if is_manager?
true
else
flash[:error] = t("admin.access.denied.app.not_manager")
auth_failed_in_backend
end
end
def for_app_sub_manager
if (@module_app.sub_managing_users.include?(current_user) || is_manager?)
true
else
flash[:error] = t("admin.access.denied.app.not_sub_manager")
auth_failed_in_backend
end
end
def for_app_user
if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager )
true
else
flash[:error] = t("admin.access.denied.app.not_authed_user")
auth_failed_in_backend
end
end
def check_object_premission(obj,title)
flash[:error] = t("admin.access.denied.object")
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? )
end end
# Render the page # Render the page
@ -82,8 +132,8 @@ class ApplicationController < ActionController::Base
# set site if exist or create site # set site if exist or create site
@site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []}) @site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []})
session[:site] = @site.id session[:site] = @site.id
@site_in_use_locales = @site.in_use_locales @site_in_use_locales = site_locales_default_head(@site.in_use_locales)
@site_valid_locales = @site.valid_locales @site_valid_locales = site_locales_default_head(@site.valid_locales)
end end
def set_current_item def set_current_item
@ -118,4 +168,14 @@ class ApplicationController < ActionController::Base
end end
end end
def site_locales_default_head(locales)
if locales[0].eql? I18n.locale.to_s
locales
else
a = Array.new(locales)
shift_out = a.delete(I18n.locale.to_s)
[shift_out] + a
end
end
end end

View File

@ -181,7 +181,7 @@ module ApplicationHelper
end end
def display_visitors(options={}) def display_visitors(options={})
Impression.where(options).distinct(:session_hash).count Impression.where(options).and(:referrer.ne => nil).distinct(:session_hash).count
end end
def display_visitors_today def display_visitors_today

View File

@ -32,6 +32,13 @@ class User
scope :remote_account, where(:nccu_id.ne => nil) scope :remote_account, where(:nccu_id.ne => nil)
def self.current
Thread.current[:user]
end
def self.current=(user)
Thread.current[:user] = user
end
def avb_apps def avb_apps
sub_role_ids_ary=self.sub_roles.collect{|t| t.id} sub_role_ids_ary=self.sub_roles.collect{|t| t.id}

View File

@ -2,8 +2,6 @@
<div id="signin-header"> <div id="signin-header">
<h3><%= t(:login) %></h3> <h3><%= t(:login) %></h3>
</div> </div>
<%= flash_messages %>
<div id="container" class="sign-in"> <div id="container" class="sign-in">
<%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %> <%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %>
<div class="content"> <div class="content">

View File

@ -15,7 +15,7 @@ Orbit::Application.configure do
config.assets.compress = true config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed # Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true config.assets.compile = false
# Generate digests for assets URLs # Generate digests for assets URLs
config.assets.digest = true config.assets.digest = true
@ -44,6 +44,7 @@ Orbit::Application.configure do
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js ) # config.assets.precompile += %w( search.js )
config.assets.precompile += %w( *.js *.css *.js.* *.css.* )
# Disable delivery errors, bad email addresses will be ignored # Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false

View File

@ -29,7 +29,7 @@ module ParserCommon
res << "'>" res << "'>"
root = "/" root = "/"
res << "<a href='#{edit ? root + admin_page_path(page.id) : (page._type.eql?('Page') ? root + page.path : page.url)}'><span>#{page.i18n_variable[I18n.locale]}</span></a>" res << "<a href='#{edit ? root + admin_page_path(page.id) : (page._type.eql?('Page') ? root + page.path : page.url)}'><span>#{page.i18n_variable[I18n.locale]}</span></a>"
if page.visible_children.size > 0 && current <= menu.levels if page.visible_children.size > 0 && current < menu.levels
res << "<span class='dot'></span>" res << "<span class='dot'></span>"
res << menu_level(page, current_page, current + 1, menu, edit) res << menu_level(page, current_page, current + 1, menu, edit)
end unless (page.root? rescue nil) end unless (page.root? rescue nil)

View File

@ -3,7 +3,7 @@
namespace :items do namespace :items do
task :tree_changes => :environment do task :tree_changes => :environment do
Item.all.each do |item| Item.all.each do |item|
item.position -= item.position > 5 ? 2 : 1 item.position -= 1
item.parent_ids = ancestors(item) item.parent_ids = ancestors(item)
item.rename(:full_name, :path) item.rename(:full_name, :path)
item.save item.save

View File

@ -11,6 +11,7 @@ class BulletinCategory
PAYMENT_TYPES = [ "List", "Picture" ] PAYMENT_TYPES = [ "List", "Picture" ]
APP_NAME = 'Announcement' APP_NAME = 'Announcement'
field :key field :key
field :display field :display

View File

@ -4,7 +4,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
include AdminHelper include AdminHelper
def preview_and_approve def preview_and_approve
@bulletin = NewsBulletin.find params[:bulletin_id] @news_bulletin = NewsBulletin.find params[:news_bulletin_id]
end end
def approve def approve

View File

@ -55,7 +55,7 @@
<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> <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 %> <% end %>
<% if news_show_approval_link(news_bulletin) %> <% if news_show_approval_link(news_bulletin) %>
<li><%= link_to t('news.news_bulletin.approval'), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin) %></li><%#= #TODO add ancher so user can quick access into that part %> <li><%= link_to t('news.news_bulletin.approval'), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin) ,:class=>"preview_trigger" %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %> <% end %>
</ul> </ul>

View File

@ -51,7 +51,7 @@ zh_tw:
list_lower: 列表 list_lower: 列表
title: 標題 title: 標題
postdate: 張貼日期 postdate: 張貼日期
approval: 公告審核 approval: 新聞審核
approval_setting: 審核設定 approval_setting: 審核設定
approval_stat: 審核狀況 approval_stat: 審核狀況
approval_pending: 待審核 approval_pending: 待審核
@ -68,7 +68,7 @@ zh_tw:
category: 分類 category: 分類
status: 狀態 status: 狀態
title: 標題 title: 標題
fact_check: 公告審核 fact_check: 新聞審核
delete: 刪除 delete: 刪除
edit: 編輯 edit: 編輯
# action: 行動 # action: 行動

View File

@ -6,8 +6,8 @@ Rails.application.routes.draw do
match 'update_setting' => "news_approvals#update_setting" ,:as => :news_approval_update_setting match 'update_setting' => "news_approvals#update_setting" ,:as => :news_approval_update_setting
resources :news_bulletins do resources :news_bulletins do
match "approve/:news_bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put match "approve/:news_bulletin_id" => "news_approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:news_bulletin_id" => "approvals#approve",:as => :approve,:via => :post match "approve/:news_bulletin_id" => "news_approvals#approve",:as => :approve,:via => :post
match "link_quick_add/:news_bulletin_id" => "news_bulletins#link_quick_add" ,:as => :link_quick_add match "link_quick_add/:news_bulletin_id" => "news_bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:news_bulletin_id" => "news_bulletins#link_quick_edit" ,:as => :link_quick_edit match "link_quick_edit/:news_bulletin_id" => "news_bulletins#link_quick_edit" ,:as => :link_quick_edit
member do member do