From 4466e7ae1ce85ee207274d9a0fa4374d75725926 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 30 Apr 2012 03:14:15 +0800 Subject: [PATCH 1/7] Fix for NCCU 0430 all functions ok with two submanagers but different behavors --- .../admin/dashboards_controller.rb | 2 +- app/controllers/admin/designs_controller.rb | 3 +- app/controllers/application_controller.rb | 52 ++++++++++++++++++- app/views/admin/dashboards/index.html.erb | 2 + app/views/layouts/_side_bar.html.erb | 4 ++ public/static/kernel.js | 1 + .../back_end/approvals_controller.rb | 1 + .../back_end/bulletin_categorys_controller.rb | 4 +- .../back_end/bulletins_controller.rb | 28 ++++++---- .../_bulletin_category.html.erb | 11 ++-- .../bulletin_categorys/index.html.erb | 2 +- .../back_end/bulletins/_bulletin.html.erb | 16 ++++-- .../back_end/bulletins/_sort_headers.html.erb | 6 ++- .../back_end/bulletins/index.html.erb | 2 + 14 files changed, 109 insertions(+), 25 deletions(-) diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index 7b761361..b7f377d3 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -2,7 +2,7 @@ class Admin::DashboardsController < ApplicationController layout "new_admin" before_filter :authenticate_user! - before_filter :is_admin? +# before_filter :is_admin? def index end diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 519b36a5..ff41c0b4 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -5,7 +5,8 @@ class Admin::DesignsController < ApplicationController layout "new_admin" before_filter :authenticate_user! - before_filter :is_admin? + before_filter :is_admin? + before_filter :for_admin_only def upload_package if !params[:design].nil? diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fb82774e..2f6636b9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -39,9 +39,59 @@ class ApplicationController < ActionController::Base @parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil end + def auth_failed_in_backend + redirect_to admin_dashboards_url + end + # Check if the current_user is admin def is_admin? - redirect_to root_url unless current_user.admin? + + auth_failed_in_backend unless current_user.admin? + end + + def is_manager? + @module_app.managing_users.include?(current_user) || is_admin? + end + + def for_admin_only + if is_admin? + true + else + flash[:notice] = "Access Denied for you are not Admin" + auth_failed_in_backend + end + end + + def for_app_manager + if is_manager? + true + else + flash[:notice] = "Access Denied for you are not Manager for this app" + 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[:notice] = "Access Denied for you are not SubManager for this app" + 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[:notice] = "Access Denied for you are not User for this app" + auth_failed_in_backend + end + end + + def check_object_premission(obj,title) + flash[:notice] = "Access Denied for you don't have permission for this object" + auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? ) end # Render the page diff --git a/app/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index d038b63d..1d9cd710 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -1,3 +1,5 @@ +<%= flash_messages %> +

Member

diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 96e0e2a8..431e8399 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -1,6 +1,10 @@ <%#= content_tag :li, :class => active_for_controllers('purchases') do -%> <%#= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %> <%# end -%> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "/static/kernel.js" %> +<% end %> +<%= flash_messages %> <%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys','module_apps', 'approvals') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> diff --git a/public/static/kernel.js b/public/static/kernel.js index c5b9a8a6..ba5b81c3 100644 --- a/public/static/kernel.js +++ b/public/static/kernel.js @@ -1,4 +1,5 @@ $(document).ready(function() { + $.each($(".notice"),function(k,v){ alert("EMPTY Cate");}); $.each($(".dymanic_load"),function(){ if($(this).attr("path")==''){$(this).html("App setting Failed");} diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 2d10dd75..4338fdd1 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -1,5 +1,6 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendController before_filter :authenticate_user! + before_filter :is_admin? include AdminHelper # layout 'admin' diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index 0e3894b9..b9151125 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -1,5 +1,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController - + before_filter :for_app_manager,:except => [:index] + + def index @bulletin_categorys = BulletinCategory.all @bulletin_category = BulletinCategory.new(:display => 'List') diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index f77e70b7..b5ebd0c0 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -1,8 +1,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController before_filter :authenticate_user! - before_filter :is_admin? - +# 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") @@ -39,6 +40,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin_file = BulletinFile.new @file_url = panel_announcement_back_end_bulletins_path + @bulletins.delete_if{ |bulletin| + bulletin.is_pending == true && (!bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || bulletin.create_user_id!=current_user.id) + } + respond_to do |format| format.html # index.html.erb format.js { } @@ -76,14 +81,17 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @bulletin.bulletin_files.build # @bulletin.bulletin_files.new - - get_categorys - get_tags - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @bulletin } - end + if get_categorys.empty? + flash[:notice] = "You dont have any permission for post on cate" + redirect_to :action => :index + else + get_tags + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @bulletin } + end + end end # GET /bulletins/1/edit @@ -311,7 +319,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController 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') + @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit') end end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb index a75440e5..8ad4578e 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb @@ -4,10 +4,13 @@ <%= bulletin_category.key %>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb index 28d2fde0..392e50a3 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb @@ -17,7 +17,7 @@ -
<%= render :partial => "form" %>
+
<%= render :partial => "form" if is_manager?%>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index b8dd663d..3722fd81 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -1,5 +1,8 @@ - <%= check_box_tag 'to_delete[]', bulletin.id, false, :class => "checkbox_in_list" %> + + <% if (bulletin.create_user_id == current_user.id) || is_manager? %> + <%= check_box_tag 'to_delete[]', bulletin.id, false, :class => "checkbox_in_list" %> + <% end -%> <% if bulletin.is_top? %> <%= t(:top) %> @@ -23,8 +26,11 @@ <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%> +
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb index b48cca39..f53ef5a6 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb @@ -2,8 +2,10 @@ - - + <% if is_manager? %> + + + <% end -%> <%= link_to (t('bulletin.status') + content_tag(:b, nil, :class => is_sort?('status'))).html_safe, panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('status'))), :class => 'js_history' %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb index 78532f00..f1a061e6 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb @@ -1,3 +1,5 @@ + + <%= form_for :bulletins, :url => delete_panel_announcement_back_end_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil), :html => {:id => 'delete_bulletins'}, :remote => true do %> <%= render 'filter' %> From a8033093806e0a98e43364dfcfca435b744c35df Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 30 Apr 2012 15:51:22 +0800 Subject: [PATCH 2/7] clean up useless flash msgs. add i18n vars for app auth and object auth --- app/controllers/application_controller.rb | 10 ++--- app/views/admin/dashboards/index.html.erb | 2 - app/views/layouts/_side_bar.html.erb | 1 - config/locales/en.yml | 8 ++++ config/locales/zh_tw.yml | 42 +++++++++++-------- public/static/kernel.js | 1 - .../back_end/bulletins_controller.rb | 2 +- .../announcement/config/locales/en.yml | 2 + .../announcement/config/locales/zh_tw.yml | 2 + 9 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2f6636b9..8fc3a90b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -57,7 +57,7 @@ class ApplicationController < ActionController::Base if is_admin? true else - flash[:notice] = "Access Denied for you are not Admin" + flash[:error] = t("admin.access.denied.not_admin") auth_failed_in_backend end end @@ -66,7 +66,7 @@ class ApplicationController < ActionController::Base if is_manager? true else - flash[:notice] = "Access Denied for you are not Manager for this app" + flash[:error] = t("admin.access.denied.app.not_manager") auth_failed_in_backend end end @@ -75,7 +75,7 @@ class ApplicationController < ActionController::Base if (@module_app.sub_managing_users.include?(current_user) || is_manager?) true else - flash[:notice] = "Access Denied for you are not SubManager for this app" + flash[:error] = t("admin.access.denied.app.not_sub_manager") auth_failed_in_backend end end @@ -84,13 +84,13 @@ class ApplicationController < ActionController::Base if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager ) true else - flash[:notice] = "Access Denied for you are not User for this app" + flash[:error] = t("admin.access.denied.app.not_authed_user") auth_failed_in_backend end end def check_object_premission(obj,title) - flash[:notice] = "Access Denied for you don't have permission for this object" + 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 diff --git a/app/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index 21bc7ffb..e22d7dac 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -1,5 +1,3 @@ -<%= flash_messages %> -

<%= t(:content) %>

diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index f479e661..dbb065f6 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -4,7 +4,6 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "/static/kernel.js" %> <% end %> -<%= flash_messages %> <%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys','module_apps', 'approvals') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 8d15763c..5a807b5a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -65,6 +65,14 @@ en: traffic: Traffic admin: + access: + denied: + app: + not_sub_manager: Access Denied for you are not SubManager for this app + not_manager: Access Denied for you are not SubManager for this app + not_authed_user: Access Denied for you are not User for this app + not_admin: Access Denied for you are not Admin + object: "Access Denied for you don't have permission for this object" action: Action ad_banner: AD Banner ad: diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index a30749e0..f0a23dde 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -8,12 +8,12 @@ zh_tw: back: 回上一步 browse: 選擇檔案 cancel: 取消 - create: 創建 + create: 新增 delete: 刪除 desktop: 桌面 disable: 禁用 dots: … - downloaded: 已經下載 + downloaded: 已下載 download: 下載 edit: 編輯 email: 電子郵件 @@ -47,7 +47,7 @@ zh_tw: file_type: 檔案類型 hits: 點擊率 item: 項目 - member: 成員 + member: 會員 module: 模組 most_visited_page: 熱門頁面 quantity: 數量 @@ -62,6 +62,14 @@ zh_tw: traffic: 流量 admin: + access: + denied: + app: + not_sub_manager: 拒絕存取因你不是此應用程式次管理員 + not_manager: 拒絕存取因你不是此應用程式管理員 + not_authed_user: 拒絕存取因你不是此應用程式授權使用者 + not_admin: 拒絕存取因你不是此應用程式次管理員 + object: 拒絕存取因你不是網站管理者 action: 操作 ad_banner: 廣告輪播 ad: @@ -81,7 +89,7 @@ zh_tw: add_item: 新增項目 add_language: 新增語言 add_drop_down_item: +增加Orbit選單 - admin: 管理 + admin: 網站管理者 all_articles: 列表 announcement: 公告管理 asset: 資產 @@ -94,22 +102,22 @@ zh_tw: author: 作者 calendar: 行事曆 cant_delete_self: 您不可以刪除自己。 - cant_revoke_self_admin: 您不可以撤銷自己的管理作用。 + cant_revoke_self_admin: 您不可以撤銷自己的管理身份。 choose_file: 請選擇一個文件... class: 階級 content: 內容 - create_error_link: 創建連接時出錯。 - create_error_page: 創建頁面時出錯。 - create_success_home: 首頁已成功創建。 - create_success_layout: 樣板已成功創建。 - create_success_link: 連結已成功創建。 - create_success_page: 頁面已成功創建。 - create_success_home: 首頁已成功創建。 - create_success_layout: 佈局已成功創建。 - create_success_link: 連結已成功創建。 - create_success_page: 頁面已成功創建。 - create_success_snippet: 片段已成功創建。 - create_success_user: 用戶已成功創建。。 + create_error_link: 新增連接時出錯。 + create_error_page: 新增頁面時出錯。 + create_success_home: 首頁已成功新增。 + create_success_layout: 樣板已成功新增。 + create_success_link: 連結已成功新增。 + create_success_page: 頁面已成功新增。 + create_success_home: 首頁已成功新增。 + create_success_layout: 佈局已成功新增。 + create_success_link: 連結已成功新增。 + create_success_page: 頁面已成功新增。 + create_success_snippet: 片段已成功新增。 + create_success_user: 用戶已成功新增。。 dashboard: 儀表板 data: 資料數據 delete_language: 刪除語言 diff --git a/public/static/kernel.js b/public/static/kernel.js index ba5b81c3..c5b9a8a6 100644 --- a/public/static/kernel.js +++ b/public/static/kernel.js @@ -1,5 +1,4 @@ $(document).ready(function() { - $.each($(".notice"),function(k,v){ alert("EMPTY Cate");}); $.each($(".dymanic_load"),function(){ if($(this).attr("path")==''){$(this).html("App setting Failed");} diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index b5ebd0c0..ff262c4d 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -83,7 +83,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @bulletin.bulletin_files.new if get_categorys.empty? - flash[:notice] = "You dont have any permission for post on cate" + flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") redirect_to :action => :index else get_tags diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 3e781823..16353b6a 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -58,6 +58,8 @@ en: announcement: all_articles: List add_new: Add + error: + no_avilb_cate_for_posting: You need a category to submit your post,please contact admin sure?: Sure? campus_news: Campus News more: more+ diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index dfe9e55f..bf0d0be6 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -37,6 +37,8 @@ zh_tw: announcement: add_new: 新增 all_articles: 列表 + error: + no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類 tags: 標籤 categories: 分類 status: 狀態 From 7a5d3ecae3fab4ac0c0ca29462a52c7a721c0f89 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 1 May 2012 16:05:05 +0800 Subject: [PATCH 3/7] Apply app_auth to ad_banner. From now,ad_banner can only be viewed for at least manager. --- app/controllers/admin/ad_banners_controller.rb | 4 ++-- app/controllers/application_controller.rb | 3 ++- app/helpers/application_helper.rb | 9 +++++++++ app/views/layouts/_side_bar.html.erb | 12 +++++++----- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index a21693aa..47d3d355 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,7 +1,7 @@ -class Admin::AdBannersController < ApplicationController +class Admin::AdBannersController < OrbitBackendController layout "new_admin" before_filter :authenticate_user! - before_filter :is_admin? + before_filter :for_app_manager def destroy @ad_banner = AdBanner.find(params[:id]) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8fc3a90b..ab01ea6b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -40,7 +40,8 @@ class ApplicationController < ActionController::Base end def auth_failed_in_backend - redirect_to admin_dashboards_url + #redirect_to admin_dashboards_url + redirect_to root_path end # Check if the current_user is admin diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 258000be..6e76b1a2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -74,6 +74,15 @@ module ApplicationHelper end end + def active_sys_call_for_app(controller_name,action_name,app_title) + unless active_for_action(controller_name,action_name).nil? + app = ModuleApp.find params[:id] + app.title == app_title ? 'active' : nil + else + nil + end + end + def active_for_controllers(*controller_names) (controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? 'active' : nil end diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index dbb065f6..1d2fc875 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -5,7 +5,7 @@ <%= javascript_include_tag "/static/kernel.js" %> <% end %> -<%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys','module_apps', 'approvals') do -%> +<%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals') || active_sys_call_for_app('module_apps','edit','Announcement') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')) do -%> <%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %> @@ -13,7 +13,7 @@ <%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= 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('admin.module.authorization'),edit_admin_module_app_path(ModuleApp.first(conditions: {title: "Announcement"}))), :class => active_for_action('module_apps', 'edit') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to(t('admin.module.authorization'),edit_admin_module_app_path(ModuleApp.first(conditions: {title: "Announcement"}))), :class => active_sys_call_for_app('module_apps','edit','Announcement') if (is_admin? rescue nil) %> <% end -%> @@ -34,13 +34,15 @@ <%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %> <% end -%> -<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') do -%> +<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') || active_sys_call_for_app('module_apps','edit','ad_banners') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.ad_banner'), admin_ad_banners_path %> - <%#= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images')) do -%> + + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images') ) do -%> <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> - <%# end %> + <%= content_tag :li, link_to(t('admin.module.authorization'),edit_admin_module_app_path(ModuleApp.first(conditions: {title: "ad_banners"}))), :class => active_sys_call_for_app('module_apps','edit','ad_banners') if (is_admin? rescue nil) %> + <% end -%> <% end %> <%= content_tag :li, :class => active_for_controllers('web_links', '/panel/web_resource/back_end/tags', 'web_link_categorys') do -%> From de457e7dfc785305102eb7d0aed47d651551e1f8 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 1 May 2012 18:23:42 +0800 Subject: [PATCH 4/7] fix broken ad_banner --- app/views/admin/ad_banners/_ad_banner_tab.html.erb | 2 +- config/routes.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index ff27d914..797624ff 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -15,7 +15,7 @@
<%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> - <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.title) , :class=>'preview_trigger btn btn-success'%> + <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.id) , :class=>'preview_trigger btn btn-success'%>
    <%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> diff --git a/config/routes.rb b/config/routes.rb index e8695f0a..c90a5ae0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,7 +25,7 @@ Orbit::Application.routes.draw do end - match 'ad_banner/:id/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put + match 'ad_banners/:id/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put resources :ad_banners do collection do match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get From 2a14c8bad496f8e496b5e8b7cc64ba56b5e26eaa Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 3 May 2012 14:57:10 +0800 Subject: [PATCH 5/7] Announcement preivew --- app/controllers/application_controller.rb | 4 +- app/controllers/pages_controller.rb | 6 +- app/helpers/application_helper.rb | 4 +- app/views/admin/ad_banners/index.html.erb | 2 +- app/views/admin/module_apps/edit.html.erb | 18 ++--- lib/parsers/parser_front_end.rb | 7 +- .../back_end/approvals_controller.rb | 7 ++ .../front_end/bulletins_controller.rb | 14 +++- .../approvals/_modal_approve.html.erb | 68 +++++++++++++++++++ .../approvals/preview_and_approve.js.erb | 5 ++ .../back_end/bulletins/_bulletin.html.erb | 2 +- .../back_end/bulletins/_form.html.erb | 22 ------ .../back_end/bulletins/index.html.erb | 2 + .../announcement/config/locales/en.yml | 1 + .../announcement/config/locales/zh_tw.yml | 1 + .../announcement/config/routes.rb | 6 +- 16 files changed, 124 insertions(+), 45 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ab01ea6b..a57b4d70 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -96,9 +96,9 @@ class ApplicationController < ActionController::Base end # Render the page - def render_page(id = nil) + def render_page(param) if @item - render :text => process_page(@item, id), :layout => 'page_layout' + render :text => process_page(@item, param[:id],param), :layout => 'page_layout' else render :text => '404 Not Found' end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 4860ea2e..fab5b6a0 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -19,7 +19,7 @@ class PagesController < ApplicationController if @item && @item.is_published case @item._type when 'Page' - render_page(params[:id]) + render_page(params) when 'Link' redirect_to "http://#{@item[:url]}" end @@ -40,7 +40,9 @@ class PagesController < ApplicationController end def show_from_link - redirect_to "/#{@item.full_name}?id=#{params[:id]}" + # debugger + # a=1 + redirect_to "/#{@item.full_name}?id=#{params[:id]}&preview=#{params[:preview]}" end def load_orbit_bar diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6e76b1a2..ab8d163f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -116,8 +116,8 @@ module ApplicationHelper ' active' if (@filter[type].include?(id.to_s) rescue nil) end - def process_page(page, id) - parse_page_noko(page, id) + def process_page(page, id,params) + parse_page_noko(page, id,params) end def page_metas(page) diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index d70afab3..47a9ec4d 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,7 +1,7 @@ <% content_for :page_specific_css do -%> <%#= stylesheet_link_tag "admin/ad_banner_preview" %> <% end -%> -<% content_for :page_specific_css do -%> +<% content_for :page_specific_javascript do -%> <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> <%= javascript_include_tag "inc/modal-preview" %> <% end -%> diff --git a/app/views/admin/module_apps/edit.html.erb b/app/views/admin/module_apps/edit.html.erb index 52142fea..7fb64d17 100644 --- a/app/views/admin/module_apps/edit.html.erb +++ b/app/views/admin/module_apps/edit.html.erb @@ -17,17 +17,17 @@
    -
    <%= t("admin.user_role.auth.sub_manager") %> - <% @module_app.sub_managers.each do |manager| %> -
    <%= manager.user.name %> <%= get_auth_by(manager) %><%= link_to '[X]',remove_sub_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:sub_manager) && manager.user != current_user %>
    - <% end %> +
    <%#= t("admin.user_role.auth.sub_manager") %> + <%# @module_app.sub_managers.each do |manager| %> +
    <%#= manager.user.name %> <%#= get_auth_by(manager) %><%#= link_to '[X]',remove_sub_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:sub_manager) && manager.user != current_user %>
    + <%# end %>
    - <%= form_tag(assign_sub_manager_admin_module_app_path) do %> - <%= collection_select(:sub_manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:sub_manager))%> - <%= submit_tag t("admin.user_role.auth.add_sub_manager") %> - <% end %> + <%#= form_tag(assign_sub_manager_admin_module_app_path) do %> + <%#= collection_select(:sub_manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:sub_manager))%> + <%#= submit_tag t("admin.user_role.auth.add_sub_manager") %> + <%# end %>
-<%= render :partial => "admin/components/user_role_management", :locals => { :object => @module_app ,:auth=> @module_app.app_auth ,:submit_url=> admin_module_app_app_auths_path(@module_app),:ploy_route_ary=>['remove',:admin,@module_app,@module_app.app_auth] } %> +<%#= render :partial => "admin/components/user_role_management", :locals => { :object => @module_app ,:auth=> @module_app.app_auth ,:submit_url=> admin_module_app_app_auths_path(@module_app),:ploy_route_ary=>['remove',:admin,@module_app,@module_app.app_auth] } %> diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index dfec0dd9..ff69a72b 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -21,10 +21,10 @@ module ParserFrontEnd require 'nokogiri' - def parse_page_noko(page, id = nil) + def parse_page_noko(page, id = nil,params) body = Nokogiri::HTML(page.design.layout.body) parse_menu(body, page) - public_r_tags = parse_contents(body, page, id) + public_r_tags = parse_contents(body, page, id,params[:preview]) parse_images(body, page) public_r_tags.each do |tag| @@ -35,7 +35,7 @@ module ParserFrontEnd end # page_contents - def parse_contents(body, page, id) + def parse_contents(body, page, id,preview = false) public_r_tags = [] body.css('.page_content').each do |content| ret = '' @@ -44,6 +44,7 @@ module ParserFrontEnd ret << "/#{id}" if id ret << "?inner=true&page_id=#{page.id}" ret << "&category_id=#{page.category}" if page[:category] + ret << "&preview=true" if preview ret << "'>
" else part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 4338fdd1..566b0742 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -3,6 +3,13 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle before_filter :is_admin? include AdminHelper # layout 'admin' + def preview_and_approve + @bulletin = Bulletin.find params[:bulletin_id] + end + + def approve + + end def setting @bulletin_categorys = BulletinCategory.all diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 8438c8e0..26739b62 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -23,10 +23,20 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end def show - @bulletin = Bulletin.can_display.where(_id: params[:id]).first - get_categorys + if params[:preview] == "true" + preview_content + else + @bulletin = Bulletin.can_display.where(_id: params[:id]).first + get_categorys + end + end + def preview_content + @bulletin = Bulletin.find params[:id] + get_categorys + render :show + end protected diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb new file mode 100644 index 00000000..8f65e341 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb @@ -0,0 +1,68 @@ + <% if bulletin -%> + + + + + +<% end -%> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb new file mode 100644 index 00000000..d0e4649d --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb @@ -0,0 +1,5 @@ +$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_approve',:locals => {:bulletin => @bulletin})) %>"); +var start_modal_with_id = "bulletin-<%=@bulletin.id%>"; +$("#"+start_modal_with_id).css("width","1050px"); +$("#"+start_modal_with_id).css("height","768px"); +$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px"); \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index 5fb1fcaa..db22e501 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -54,7 +54,7 @@ <% end -%> <% if show_approval_link(bulletin) %> -
  • <%= link_to t('announcement.bulletin.approval'), edit_panel_announcement_back_end_bulletin_path(bulletin) %>
  • <%#= #TODO add ancher so user can quick access into that part %> +
  • <%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %>
  • <%#= #TODO add ancher so user can quick access into that part %> <% end %>
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index df86f221..d9771e83 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -105,28 +105,6 @@ -

    Audit

    -
    - - <% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin? %> -
    - <%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %> - <%= content_tag :label,:class => "radio inline" do -%> - <%= f.radio_button :is_checked, true , {:class => 'privacy'} %> - <%= t('announcement.bulletin.approval_pass') %> - <% end -%> - <%= content_tag :label,:class => "radio inline" do -%> - <%= f.radio_button :is_checked, false, (!@bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%> - <%= t('announcement.bulletin.approval_not_pass') %> - <% end -%> -
    - <%= label :is_checked_false, t('announcement.bulletin.approval_not_pass_reason') %> - <%= f.text_field :not_checked_reason %> -
    - -
    - <% end %> -
    <% elsif current_user.admin? %> <%= f.hidden_field :is_checked,:value => true%> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb index 54c0ab7a..4220edf4 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb @@ -23,5 +23,7 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "bulletin_form" %> + <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> + <%= javascript_include_tag "inc/modal-preview" %> <% end %> diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 16353b6a..f88490e4 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -81,6 +81,7 @@ en: approval_setting_window_title: 'Unit' approval_user_list: 'Approval Users' cate_auth: Category Authorization + submit_approval: Submit approval # admin: # action: Action # add_language: Add language diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index bf0d0be6..d0b6d73e 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -63,6 +63,7 @@ zh_tw: approval_setting_window_title: '單位' approval_user_list: '審核者' cate_auth: '分類授權' + submit_approval: '提交審核' bulletin: last_modified: 最後修改於 diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 0de9877a..f2c5092f 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -7,6 +7,8 @@ Rails.application.routes.draw do match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put resources :bulletins do + match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put + match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit member do @@ -32,7 +34,9 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do - resources :bulletins + resources :bulletins # do + # match "preview" => "bulletins#preview_content",:as => :get_preview_content + # end end namespace :widget do match "bulletins" => "bulletins#index" From eb81aa6980b35627ccead9c53a61ecce3a72010e Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 3 May 2012 15:48:42 +0800 Subject: [PATCH 6/7] disable input --- .../announcement/back_end/approvals/_modal_approve.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb index 8f65e341..35049b98 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb @@ -57,6 +57,7 @@ //Disable all default actions e.preventDefault(); }); + $('input', frameBody).attr("disabled", true); }); }); From b89975b4c4721841ac71d9405599143fec05cf02 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 3 May 2012 18:27:39 +0800 Subject: [PATCH 7/7] add field called unit_list_for_anc and data from nccu(0224). Now can run "rake nccu_data:setup_ut_list" to setup NCCU data. --- .../back_end/bulletins_controller.rb | 1 + .../announcement/app/models/bulletin.rb | 1 + .../app/models/unit_list_for_anc.rb | 12 ++ .../back_end/bulletins/_form.html.erb | 3 + .../front_end/bulletins/show.html.erb | 2 +- .../data_for_ut_list_for_posting_anc.rake | 15 ++ .../lib/ut_list_from_nccu_2012feb.csv | 186 ++++++++++++++++++ 7 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 vendor/built_in_modules/announcement/app/models/unit_list_for_anc.rb create mode 100644 vendor/built_in_modules/announcement/lib/tasks/data_for_ut_list_for_posting_anc.rake create mode 100644 vendor/built_in_modules/announcement/lib/ut_list_from_nccu_2012feb.csv diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index ff262c4d..6a8ad109 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -316,6 +316,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController 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? diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 55d1ec84..b01de8ea 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -33,6 +33,7 @@ class Bulletin mount_uploader :image, ImageUploader belongs_to :bulletin_category + belongs_to :unit_list_for_anc # embeds_many :bulletin_links, :cascade_callbacks => true # embeds_many :bulletin_files, :cascade_callbacks => true diff --git a/vendor/built_in_modules/announcement/app/models/unit_list_for_anc.rb b/vendor/built_in_modules/announcement/app/models/unit_list_for_anc.rb new file mode 100644 index 00000000..5261f6a2 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/models/unit_list_for_anc.rb @@ -0,0 +1,12 @@ +class UnitListForAnc + include Mongoid::Document + include Mongoid::Timestamps + + field :order + field :ut_code + field :up_ut_code + + has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true + + +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index d9771e83..015b636a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -117,6 +117,9 @@
    + + <%= 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.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index 2f37df9c..5c0857cd 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -4,7 +4,7 @@
    diff --git a/vendor/built_in_modules/announcement/lib/tasks/data_for_ut_list_for_posting_anc.rake b/vendor/built_in_modules/announcement/lib/tasks/data_for_ut_list_for_posting_anc.rake new file mode 100644 index 00000000..e5bd0be2 --- /dev/null +++ b/vendor/built_in_modules/announcement/lib/tasks/data_for_ut_list_for_posting_anc.rake @@ -0,0 +1,15 @@ +# encoding: utf-8 + +namespace :nccu_data do + desc "load nccu data from csv" + task :setup_ut_list => :environment do + require 'csv' + + CSV.foreach("vendor/built_in_modules/announcement/lib/ut_list_from_nccu_2012feb.csv") do |row| + new_unit = UnitListForAnc.new(:order => row[0], :ut_code => row[1], :up_ut_code => row[2], :created_at => Time.now,:updated_at => Time.now) + new_unit.build_title :en => row[4], :zh_tw => row[3] + new_unit.save + end + + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/lib/ut_list_from_nccu_2012feb.csv b/vendor/built_in_modules/announcement/lib/ut_list_from_nccu_2012feb.csv new file mode 100644 index 00000000..548ad528 --- /dev/null +++ b/vendor/built_in_modules/announcement/lib/ut_list_from_nccu_2012feb.csv @@ -0,0 +1,186 @@ +order,ut_code,up_tu_code,ut_zh_tw,ut_en +0100,H00,H00,校長室,Office of the President +0110,H01,H01,副校長室一,Office of the Vice President +0110,H03,H03,副校長室二,Office of the Vice President +0200,100,100,文學院,College of Liberal Arts +0210,101,100,中文系,Dept. of Chinese Literature +0220,103,100,歷史系,Dept. of History +0230,104,100,哲學系,Dept. of Philosophy +0240,155,100,圖檔所,"Graduate Institute of Library, Informati" +0250,156,100,宗教所,Graduate Institute of Religious Studies +0260,158,100,台史所,Graduate Institute of Taiwan History +0270,159,100,台文所,Graduate Institute of Taiwan Literatu +0280,161,100,華文碩,Master's Program in Teaching Chinese as +0290,160,100,華文博,Doctor's Program in Teaching Chinese as +0294,913,100,圖資專班,E-learning Master Program of Library and +0300,700,700,理學院,College of Science +0310,701,700,應數系,Dept. of Mathematical Sciences +0320,702,700,心理系,Dept. of Psychology +0330,703,700,資科系,Dept. of Computer Science +0340,754,700,神科所,The Graduate Institute of Neuroscience +0350,755,700,應物所,Graduate Institute of Applied Physics +0600,200,200,社科院,College of Social Sciences +0605,202,200,政治系,Dept. of Political Science +0610,204,200,社會系,Dept. of Sociology +0615,205,200,財政系,Dept. of Public Finance +0620,206,200,公行系,Dept. of Public Administration +0625,207,200,地政系,Dept. of Land Economics +0630,208,200,經濟系,Dept. of Economics +0635,209,200,民族系,Dept. of Ethnology +0640,261,200,國發所,GIDS +0645,262,200,勞工所,Graduate Institute of Labor Research +0650,264,200,社工所,Graduate Institute of Social Work +0652,265,200,亞太博,International Doctor Program in Asia-Pac +0700,600,600,法學院,College of Law +0710,601,600,法律系,Dept. of Law +0720,652,600,法科所,The Institute of Law and Inter-disciplin +0800,300,300,商學院,College of Commerce +0801,301,300,國貿系,Dept. of International Business +0803,302,300,金融系,Dept. of Money and Banking +0805,303,300,會計系,Dept. of Accounting +0807,304,300,統計系,Dept. of Statistics +0809,305,300,企管系,Dept. of Business Administration +0811,306,300,資管系,Dept. of Management Information System +0813,307,300,財管系,Dept. of Finance +0815,308,300,風管系,Dept. of Risk Management and Insurance +0817,359,300,科管所,Graduate Institute of Technology and Inn +0819,361,300,智財所,Graduate Institute of Intellectual Prope +0821,362,300,管理碩士學程,Advanced Master of Business Administrati +0823,380,300,商管碩,Advanced Master of Business Administrati +1100,500,500,外語學院,College of Foreign Languages +1110,501,500,英文系,Dept. of English +1120,502,500,阿文系,Dept. of Arabic Language and Literature +1130,504,500,斯拉夫文系,Dept. of Slavic Languages and Literature +1140,506,500,日文系,Dept. of Japanese +1150,507,500,韓文系,Dept. of Korean Language and Cultur +1160,508,500,土文系,Dept. of Turkish Language and Cultu +1170,555,500,語言所,Graduate Institute of Linguistics +1180,509,500,歐洲語文學程,Undergraduate Program in European Langua +1190,5T1,500,外文中心,Foreign Languages Center +1200,400,400,傳播學院,College of Communication +1210,401,400,新聞系,Dept. of Journalism +1220,402,400,廣告系,Dept. of Advertising +1230,403,400,廣電系,Dept. of Radio and Television +1240,461,400,國傳英語碩士學位學程,International Master's Program in Intern +1250,404,400,傳播學程,College of Communication Undergraduate D +1260,462,400,數位內容學程,DCT +1270,781,700,數位內容與科技學士學位學程,數位內容與科技學士學位學程 +1280,4A1,400,實習廣播電台,NCCU Community Radio Station +1300,800,800,國際事務學院,College of International Affairs +1310,203,800,外交系,Dept. of Diplomacy +1320,260,800,東亞所,Graduate Institute of East Asian Studies +1330,263,800,俄研所,Graduate Institute of Russian Studies +1340,861,800,日碩研,Master Program in Japan Studies +1346,862,800,國際研究英語碩士學位學程(籌備處),International Master's Program in Intern +1600,900,900,教育學院,College of Education +1610,102,900,教育系,Dept. of Education +1620,157,900,幼教所,Graduate Institute of Early Childhood Ed +1630,171,900,教政所,Graduate Institute of Educational Admini +1640,1T3,900,師培中心,Institute of Teacher Education +1652,172,900,輔諮碩學程,MPCG +1660,1T1,900,教研中心,The Teacher In-Service Education Center +1700,L00,L00,國關中心,The Institute of International Relations +1710,L01,L00,國關第一所,First Division +1720,L02,L00,國關第二所,Second Division +1730,L03,L00,國關第三所,Third Division +1740,L04,L00,國關第四所,Fourth Division +1750,L05,L00,國關合交組,The Institute of International Relations +1760,L06,L00,國關編譯組,The Institute of International Relations +1770,L07,L00,國關圖資組,The Institute of International Relations +1780,L08,L00,國關秘書組,The Institute of International Relations +1800,S00,S00,選研中心,Election Study Center +1900,Z01,Z01,第三部門研究中心,Center for the Third Sector +1910,Z02,Z02,創新創造力研究中心,CCIS +1920,Z03,Z03,中國大陸研究中心,Center for China Studies +1930,Z04,Z04,台灣研究中心,TSC +1940,Z08,Z08,心腦學中心,"Reseach Center for Mind, Brain and Learn" +1950,Z10,Z10,原民中心,Center for Aboriginal Studies +1960,Z09,Z09,人文中心,Humanities Center +2000,T00,T00,教務處,Office of Academic Affairs +2010,T01,T00,教務處註冊組,Registration Section +2020,T02,T00,教務處課務組,Instruction Resources Section +2030,T03,T00,教務處綜合業務組,Admission Section +2040,T04,T00,教務處通識教育中心,Center of General Education +2100,M00,M00,學務處,Office of Student Affairs +2110,M01,M00,學務處生僑組,Life Guidance and Overseas Chinese Stude +2120,M02,M00,學務處課外組,Student Activities Section +2130,M03,M00,學務處住宿組,Student Housing Service Section +2150,M11,M00,學務處藝文中心,Art and Culture Center +2155,M14,M00,學務處身心健康中心,Physical and Mental Health Center +2160,M13,M00,學務處職涯中心,Center of Career Development +2170,D00,M00,學務處軍訓室,Military Education Office +2200,G00,G00,總務處,Office of General Affairs +2210,G01,G00,總務處文書組,Document and postal section +2220,G02,G00,總務處事務組,General Management Section +2230,G05,G00,總務處出納組,Cashier Section +2240,G04,G00,總務處營繕組,Construction and Maintenance Section +2250,G03,G00,總務處財產組,Property Management SEction +2260,G06,G00,總務處環保組,Environmental Protection Section +2270,G08,G00,總務處規劃組,Campus Planning & Devel opment Section +2280,G07,G00,總務處駐警隊,Campus Security National Chengchi Unive +2300,R00,R00,研發處,Office of Research and Development +2310,R01,R00,研發處企畫組,Planning Section +2320,R02,R00,研發處學術推展組,Academic Development Section +2330,R03,R00,研發處學評組,Academic Evaluation Section +2400,Z05,Z05,國合處,Office of International Cooperation +2410,Z06,Z05,國合處合作交流組,CES +2420,Z07,Z05,國合處教育組,IES +2430,Z14,Z05,國合處發展策劃組,DPS +2500,Q00,Q00,秘書處,Secretariat +2510,Q01,Q00,秘書處第一組,First Section +2520,Q02,Q00,秘書處第二組,Second Section +2530,Q03,Q00,秘書處第三組,Third Section +2600,K00,K00,圖書館,Libraries +2610,K06,K00,圖書館資訊組,System Information Section +2620,K07,K00,圖書館採編組,Acquisition & Cataloging Section +2630,K08,K00,圖書館典閱組,Circulation Section +2640,K09,K00,圖書館推廣服務組,Reference Services Section +2650,K10,K00,圖書館數位典藏組,Digital Preservation Section +2660,K11,K00,圖書館行政組,Administration Section +2670,K12,K00,圖書館圖書分館,Branch Libraries +2700,B00,B00,體育室,Physical Education Office +2710,B01,B00,體育教學組,Physical Education Office +2720,B02,B00,體育活動組,Sport activities section +2800,P00,P00,人事室,Personnel Office +2810,P01,P00,人一組,First Section +2820,P02,P00,人二組,Second Section +2830,P03,P00,人三組,Third Section +2840,P04,P00,人四組,Fourth Section +2900,A00,A00,會計室,Accounting Office +2910,A01,A00,會計室第一組,Budgeting Section +2920,A02,A00,會計室第二組,Accounting Section +2930,A03,A00,會計室第三組,Auditing Section +3000,I00,I00,公企中心,Public and Business Administration Educa +3010,I01,I00,公企諮詢組,Research and Consultation Section +3020,I02,I00,公企職訓組,Training Section +3030,I03,I00,公企語訓組,Language Training Section +3040,I04,I00,公企總務組,General Affairs Section +3050,I05,I00,公企中心圖資組,Library Resource Section +3100,O00,O00,公教中心,Civil Service Education Center +3110,O01,O00,公教教務組,Civil Service Education Center +3120,O02,O00,公教輔導組,Civil Service Education Center +3130,O03,O00,公教行政組,Civil Service Education Center +3200,J00,J00,社資中心,Social Sciences Information Center +3210,J03,J00,社資資料組,Reference Services Section +3220,J04,J00,社資研發組,Section of Research & Development +3300,C00,C00,電算中心,Computer Center +3310,C01,C00,電算教研組,Teaching and Research Section +3320,C02,C00,電算系統組,Application System Section +3330,C03,C00,電算行政組,Administration and Counseling Section +3340,C04,C00,電算網路組,Networking and Development Section +3400,T05,T05,教學發展中心,Center for Teaching and Learning Develop +3410,T06,T05,教發教學組,Teaching and Learning Division +3420,T07,T05,教發數位組,E-Learning Division +3430,T08,T05,教發規劃組,Planning and Research Division +3500,162,162,華語文中心,Chinese Language Center +3600,Z11,Z11,育成中心,Innovation Incubation Center +3700,V00,V00,附設實小,The Experimental Elementary School +3700,V01,V00,附設實小教務處,Office of Academic Affairs +3700,V02,V00,附設實小學務處,Office of Student Affairs +3700,V03,V00,附設實小輔導室,The Experimental Elementary School +3700,V04,V00,附設實小總務處,Office of General Affairs +3700,V06,V00,附設實小研究處,The Experimental Elementary School +3710,V05,V00,附設實小幼稚園,The Experimental Elementary School +3800,W00,W00,附中,The Affiliated High School +3900,Z13,Z13,政大書院辦公室,Chengchi College Project Office +4000,Z12,Z12,頂大辦公室,Office of NCCU Top University Program \ No newline at end of file