From 0306277c3d901fe0a77f37695380aaad39a52bb0 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 18 May 2012 10:50:53 +0800 Subject: [PATCH 01/27] fix view for different_user for ad_banner. add field 'best size' for ad_banner within form --- app/controllers/admin/ad_banners_controller.rb | 2 +- app/controllers/admin/ad_images_controller.rb | 6 +++--- app/views/admin/ad_banners/_ad_banner_tab.html.erb | 4 ++++ .../admin/ad_banners/_modal_ad_banner_form.html.erb | 7 +++++++ app/views/admin/ad_banners/index.html.erb | 11 ++++++++--- app/views/admin/ad_images/_form.html.erb | 5 ++++- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + 8 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index cd436a12..f43c19e5 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,7 +1,7 @@ class Admin::AdBannersController < OrbitBackendController layout "new_admin" before_filter :authenticate_user! - before_filter :for_app_manager,:except => [:index,:show] + before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview] before_filter :for_app_sub_manager def rename diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 945629ed..e3cef303 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -1,8 +1,8 @@ -class Admin::AdImagesController < ApplicationController +class Admin::AdImagesController < OrbitBackendController layout 'new_admin' before_filter :authenticate_user! - before_filter :is_admin? - + before_filter :for_app_sub_manager + def edit @ad_banner = AdBanner.find params[:ad_banner_id] @ad_image = @ad_banner.ad_images.find params[:id] 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 ca98e42e..d65a17e0 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -7,6 +7,10 @@ <%= f.select :ad_fx ,AdBanner::FX_TYPES %> <%= f.label :transition_sec, t('admin.ad.transition_sec') %> <%= f.text_field :transition_sec,:placeholder=>t('admin.ad.sec_place_holder'),:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> + <%if at_least_module_manager%> + <%= f.label :best_size, t('admin.ad.best_size') %> + <%= f.text_field :best_size %> Ex: 500px x 300px + <% end -%>
<%= f.submit t("admin.ad.update_banner"), :class => 'btn' %> <%= f.submit t("cancel"),:type=>'reset', :class => 'btn' %> diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index cbc4de8e..68e0a9c6 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -21,6 +21,13 @@ <%= f.text_field :transition_sec %> <%= t("admin.ad.trans_unit_sec") %> + +
+ <%= f.label :best_size, t('admin.ad.best_size'),:class => "control-label" %> +
+ <%= f.text_field :best_size %> Ex: 500px x 300px +
+
<%= f.label :ad_fx, t('admin.ad.ab_fx') %> diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index b4be090f..92c78f5b 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -13,11 +13,16 @@ diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 1513fa05..edbb2563 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -80,7 +80,10 @@ <%= image_tag @ad_image.file rescue ''%>
- <%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) if !@ad_image.ad_banner.best_size.empty?%> + <% if !@ad_image.ad_banner.best_size.empty?%> + <%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) %> + + <% end -%>
+ +
+ <%= f.label :best_size, t('admin.ad.best_size'),:class => "control-label" %> +
+ <%= f.text_field :best_size %> Ex: 500px x 300px +
+
<%= f.label :ad_fx, t('admin.ad.ab_fx') %> diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index b4be090f..92c78f5b 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -13,11 +13,16 @@ diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 1513fa05..edbb2563 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -80,7 +80,10 @@ <%= image_tag @ad_image.file rescue ''%>
- <%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) if !@ad_image.ad_banner.best_size.empty?%> + <% if !@ad_image.ad_banner.best_size.empty?%> + <%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) %> + + <% end -%>
- <%= link_to t("announcement.bulletin.approval_user_list"), panel_announcement_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%> - <%#= label_tag :role, t("admin.roles") %>
diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb index 80838ec5..20a3d3eb 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb @@ -4,7 +4,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController include AdminHelper def preview_and_approve - @bulletin = NewsBulletin.find params[:bulletin_id] + @news_bulletin = NewsBulletin.find params[:news_bulletin_id] end def approve @@ -35,10 +35,27 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController end def update_setting - + object_auth = update_setting_by_params + if object_auth.save! + flash[:notice] = t("admin.object_auth.update_done") + else + flash[:notice] = t("admin.object_auth.update_failed") + end + end + + def user_list + @news_bulletin_category = NewsBulletinCategory.find params[:category_id] end protected + def update_setting_by_params + category = NewsBulletinCategory.find params[:category_id] + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check') + object_auth = object_auth_ary.first + object_auth.privilege_users = privilege_users + object_auth + end def get_categorys(id = nil) @news_bulletin_categorys = [] diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb index 50b9c266..b4f5fc82 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/front_end/news_bulletins_controller.rb @@ -36,9 +36,8 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController end def preview_content - @news_bulletins = NewsBulletin.find params[:id] + @news_bulletin = NewsBulletin.find params[:id] get_categorys - render :show end protected diff --git a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb index 666bcf4e..8bf47a3d 100644 --- a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb +++ b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb @@ -2,7 +2,7 @@ module Panel::News::BackEnd::NewsBulletinsHelper def news_show_approval_link(news_bulletin) by_news_bulletin = (!news_bulletin.is_expired? and !news_bulletin.is_checked?) - by_user = news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) or is_manager? + by_user = (news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) or is_manager? or is_admin?) by_news_bulletin and by_user end diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_modal_list.html.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_modal_list.html.erb new file mode 100644 index 00000000..9c999830 --- /dev/null +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_modal_list.html.erb @@ -0,0 +1,44 @@ +<% if news_bulletin_category -%> + +