From 0a9f0bcc45521663b20f2232323cea9080917a03 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 15 May 2012 09:57:05 +0800 Subject: [PATCH] starting ad_banner auth --- app/helpers/admin/ad_banner_helper.rb | 10 ++++++++++ app/models/ad_banner.rb | 4 ++-- app/views/admin/ad_banners/_ad_banner_tab.html.erb | 3 +++ config/locales/zh_tw.yml | 1 + .../panel/announcement/back_end/bulletins_helper.rb | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/helpers/admin/ad_banner_helper.rb b/app/helpers/admin/ad_banner_helper.rb index eff12427..f21c5e73 100644 --- a/app/helpers/admin/ad_banner_helper.rb +++ b/app/helpers/admin/ad_banner_helper.rb @@ -12,5 +12,15 @@ module Admin::AdBannerHelper printable_ad_images.shuffle! end + def show_ad_banner_permission_link(ad_banner) + type = 'edit' + oa = ad_banner.get_object_auth_by_title(type) + if oa.nil? + ad_banner.object_auths.new(title: type ).save + oa = ad_banner.get_object_auth_by_title(type) + end +# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) + link_to t('admin.ad.cate_auth'),admin_object_auth_ob_auth_path(oa) + end end \ No newline at end of file diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index e1013c2f..6163a81f 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -1,9 +1,9 @@ class AdBanner - include OrbitCoreLib::ObjectAuthable include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - + include OrbitCoreLib::ObjectAuthable + field :title field :transition_msec,type: Integer field :ad_fx #TODO Design should explain 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 797624ff..7074717f 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -20,6 +20,9 @@ + <% if is_manager? || is_admin? %> + <%= show_ad_banner_permission_link ad_banner_tab%> + <% end -%> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> <% end -%> diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 7c2ac289..a27f67bc 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -76,6 +76,7 @@ zh_tw: sec_place_holder: 3秒請輸入3 ab_fx: 轉場特效 all_banners: 輪播清單 + cate_auth: 分類授權 banner_best_size: Banner 尺寸 new_banner: 新增輪播 new_image: 新增橫幅 diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb index 8e6b9bff..68286c3e 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -2,7 +2,7 @@ module Panel::Announcement::BackEnd::BulletinsHelper def show_approval_link(bulletin) by_bulletin = (!bulletin.is_expired? and !bulletin.is_checked?) - by_user = (bulletin.bulletin_category.authed_users('fact_check').include?(current_user) or is_manager?) + by_user = (bulletin.bulletin_category.authed_users('fact_check').include?(current_user) or is_manager? or is_admin?) by_bulletin and by_user end