From 6ce6577e83702ce375d4f869f7c3d1bb96a145f3 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 18 May 2012 18:47:18 +0800 Subject: [PATCH] fix news approve and preview --- app/views/layouts/_side_bar.html.erb | 2 +- .../back_end/approvals_controller.rb | 4 +- .../front_end/bulletins_controller.rb | 1 - .../back_end/approvals/setting.html.erb | 2 - .../back_end/news_approvals_controller.rb | 21 ++++++++- .../front_end/news_bulletins_controller.rb | 3 +- .../news/back_end/news_bulletins_helper.rb | 2 +- .../news_approvals/_modal_list.html.erb | 44 +++++++++++++++++++ .../news_approvals/_privilege_user.html.erb | 2 +- .../back_end/news_approvals/setting.html.erb | 14 +++--- .../news_approvals/update_setting.js.erb | 1 + .../back_end/news_approvals/user_list.js.erb | 2 + .../news_bulletins/_news_bulletin.html.erb | 2 +- vendor/built_in_modules/news/config/routes.rb | 11 ++--- 14 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/_modal_list.html.erb create mode 100644 vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/update_setting.js.erb create mode 100644 vendor/built_in_modules/news/app/views/panel/news/back_end/news_approvals/user_list.js.erb diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index ab5981a8..8518688a 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -26,7 +26,7 @@ <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_news_back_end_news_bulletin_path), :class => active_for_action('news_bulletins', 'new') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_news_back_end_news_bulletin_categorys_path), :class => active_for_action('news_bulletin_categorys', 'index') || active_for_ob_auths_object("NewsBulletinCategory") %> <%= content_tag :li, link_to(t('announcement.tags'), panel_news_back_end_tags_path), :class => active_for_action('/panel/news/back_end/tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_news_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %> + <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %> <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "news"}))), :class => active_for_app_auth('news') if (is_admin? rescue nil) %> <% end -%> 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 e5c92023..0177cd12 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 @@ -31,9 +31,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle def update_setting object_auth = update_setting_by_params if object_auth.save! - flash[:notice] = "Update Done" + flash[:notice] = t("admin.object_auth.update_done") else - flash[:notice] = "Update Failed" + flash[:notice] = t("admin.object_auth.update_failed") end end 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 f21c1a38..9fd97b9b 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 @@ -38,7 +38,6 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController 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/setting.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.html.erb index 9e6c7225..57d3105b 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/setting.html.erb @@ -16,11 +16,9 @@ <%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %> <%= search_field_tag 'user_filter' %> - <%= 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 -%> + +