From ee6dcf238f433edcd49180f3beafa73b5e81ff42 Mon Sep 17 00:00:00 2001 From: Spen Date: Thu, 13 Feb 2014 16:13:54 +0800 Subject: [PATCH] Fix approval issue --- app/controllers/orbit_backend_controller.rb | 1 + app/helpers/orbit_backend_helper.rb | 6 +++--- app/models/module_app.rb | 1 + config/locales/en.yml | 6 ++++++ config/locales/zh_tw.yml | 3 +++ lib/orbit_core_lib.rb | 2 +- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 3a6a7594..2759089b 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -1,6 +1,7 @@ class OrbitBackendController < ApplicationController include OrbitCategory::Categorizing include OrbitCoreLib::Authorization + include OrbitCoreLib::PermissionUtility include OrbitTag::Tagging include AdminHelper include ApplicationHelper diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index a55de39d..2867dd68 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -12,13 +12,13 @@ module OrbitBackendHelper def show_form_status_field(object) #by_object = (!object.is_expired? and object.is_pending?) - by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?) + by_user = ((object.category.user_is_authorized_by_title?(current_user,"category_approval_#{@module_app.key}") rescue nil) or is_manager? or is_admin?) by_user end def show_approval_link(object) by_object = (!object.is_expired? and object.is_pending?) - by_user = ((object.category.authed_users("approval_#{@module_app.key}").include?(current_user) rescue nil) or is_manager? or is_admin? or is_sub_manager?) + by_user = ((object.category.user_is_authorized_by_title?(current_user,"category_approval_#{@module_app.key}") rescue nil) or is_manager? or is_admin?) by_object and by_user end @@ -306,7 +306,7 @@ module OrbitBackendHelper content_tag :li, link_to(t(quick[:translation] || :authorization_), eval("#{quick[:link]}"), class: "preview_trigger #{quick[:class]}") end when 'edit' - if authorization && approvable + if authorization && approvable || is_manager? content_tag :li, link_to(t(quick[:translation] || :edit), quick[:link].nil? ? '#' : eval("#{quick[:link]}('#{object.id}'#{link_option})"), class: quick[:class], data: eval("#{quick[:data]}")) end when 'delete' diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 61673ec2..9a5cb374 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -194,6 +194,7 @@ class ModuleApp # authorization def update_auth_approval_users user_ids = self.auth_approvals.inject([]) do |users, auth| + auth = auth.class.find(auth.id) users += auth.authorized_users.map{|user| user.id} end self.update_attribute(:auth_approval_users, user_ids.uniq) diff --git a/config/locales/en.yml b/config/locales/en.yml index 86a2101c..df6d5e11 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -225,11 +225,13 @@ en: groups: Groups help: Help hidden: Hidden + is_hidden: Hidden hide: Hide hits: Hits homepage: Homepage horizontal: Horizontal hot: Hot + is_hot: Hot image: Image images: Images info: Information @@ -345,11 +347,13 @@ en: public_r_tag: System Widget text: Text Area passed: Approved + is_checked: Approved password: Password password_change: Change password password_confirmation: Password confirmation password_current: Current password pending: Pending + is_pending: Pending personal_plugins: author : "Author" edit_brief_intro : "Edit Brief Intro." @@ -392,6 +396,7 @@ en: register: Register registered: Registered rejected: Rejected + is_rejected: Rejected rejected_reason: 'Reason:' rejected_reason_empty: "Approval rejected, no referencable information" related_links: Related Links @@ -519,6 +524,7 @@ en: to_search: Set as Search Key to_show: Display in frontend top: Top + is_top: Top total_visitors: Total Visitors traffic: Traffic type: Field Type diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index a5493fb6..8176e8e0 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -348,11 +348,13 @@ zh_tw: public_r_tag: 系統模塊 text: 文字區域 passed: 通過審核 + is_checked: 通過審核 password: 密碼 password_change: 更改密碼 password_confirmation: 確認密碼 password_current: 目前的密碼 pending: 待審核 + is_pending: 待審核 personal_plugins: author : "著作人" edit_brief_intro : "編輯摘要" @@ -394,6 +396,7 @@ zh_tw: register: 註冊 registered: 已註冊 rejected: 拒絕 + is_rejected: 拒絕 rejected_reason: 拒絕原因:' rejected_reason_empty: "拒絕核准, 沒有參考資訊" related_links: 相關連結 diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb index b44b32e9..e0c5f6e4 100644 --- a/lib/orbit_core_lib.rb +++ b/lib/orbit_core_lib.rb @@ -234,7 +234,7 @@ module OrbitCoreLib when :sub_manager @open ||= check_sub_manager when :approver - @open ||= check_sub_manager + @open ||= check_approver when :user @open ||= true when :visitor