From 13b6892f873e625aeff2ce7b640b2a2d9ee4d586 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 11:09:44 +0800 Subject: [PATCH] code for new fact check --- app/controllers/orbit_backend_controller.rb | 1 + app/views/layouts/_side_bar.html.erb | 1 + lib/tasks/anc_tasks.rake | 12 +-- .../back_end/bulletins_controller.rb | 7 +- .../back_end/fact_checks_controller.rb | 92 +++++++++++++------ .../announcement/app/models/bulletin.rb | 3 + .../back_end/bulletins/_bulletin.html.erb | 5 +- .../back_end/bulletins/_form.html.erb | 13 ++- .../back_end/bulletins/_quick_edit.html.erb | 10 +- .../back_end/bulletins/index.html.erb | 1 - .../back_end/fact_checks/_list_table.html.erb | 15 --- .../back_end/fact_checks/index.html.erb | 40 -------- .../announcement/config/locales/en.yml | 6 ++ .../announcement/config/locales/zh_tw.yml | 7 ++ .../announcement/config/routes.rb | 5 +- 15 files changed, 114 insertions(+), 104 deletions(-) delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index d3639ebe3..b52384c6a 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -4,6 +4,7 @@ class OrbitBackendController< ApplicationController # before_filter {|c| c.front_end_available(@app_title)} before_filter :check_user_can_use,:except => [:public] include OrbitCoreLib::PermissionUnility + include AdminHelper layout 'admin' diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 33e415977..d287e46c1 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -9,6 +9,7 @@ <%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %> + <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') %> <% end -%> <% end -%> diff --git a/lib/tasks/anc_tasks.rake b/lib/tasks/anc_tasks.rake index 3145d1192..cd534b939 100644 --- a/lib/tasks/anc_tasks.rake +++ b/lib/tasks/anc_tasks.rake @@ -11,12 +11,12 @@ namespace :anc do bulletin_category_3.create_i18n_variable(:en => "MattCheckChrisPreview", :zh_tw => 'MattCheckChrisPreview') - bulletin_1 = Bulletin.create(:title => "C1P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) - bulletin_2 = Bulletin.create(:title => "C1P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) - bulletin_3 = Bulletin.create(:title => "C2P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) - bulletin_4 = Bulletin.create(:title => "C2P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) - bulletin_5 = Bulletin.create(:title => "C3P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) - bulletin_6 = Bulletin.create(:title => "C3P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) + bulletin_1 = Bulletin.create(:title => "C1P1",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) + bulletin_2 = Bulletin.create(:title => "C1P2",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) + bulletin_3 = Bulletin.create(:title => "C2P1",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) + bulletin_4 = Bulletin.create(:title => "C2P2",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) + bulletin_5 = Bulletin.create(:title => "C3P1",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) + bulletin_6 = Bulletin.create(:title => "C3P2",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) end end \ No newline at end of file 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 dcd3de045..e8eb6149f 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,5 +1,4 @@ -class Panel::Announcement::BackEnd::BulletinsController < ApplicationController - +class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController layout 'new_admin' before_filter :authenticate_user! @@ -151,7 +150,6 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController elsif is_sub_manager? @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') end -<<<<<<< HEAD end def get_sorted_bulletins @@ -196,8 +194,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController a.flatten! a.uniq end -======= ->>>>>>> 26cd6951dba43b1f6eaf5056160309c5c77a8716 + end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb index dd4719589..c47e91fb4 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb @@ -1,38 +1,76 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendController before_filter :authenticate_user! include AdminHelper - layout 'admin' + # layout 'admin' + layout 'new_admin' - def index - @bulletin_categorys_submit_new = [] - @bulletin_categorys_check =[] - if is_admin? || is_manager? - #@bulletin_categorys_submit_new = BulletinCategory.all - @bulletin_categorys_check = BulletinCategory.all - # elsif is_sub_manager? - # @bulletin_categorys_submit_new = BulletinCategory.authed_for_user(current_user,'submit_new') - # @bulletin_categorys_check = BulletinCategory.authed_for_user(current_user,'fact_check') + def setting + @bulletin_categorys = BulletinCategory.all + if params.has_key?(:category_id) + first_category = BulletinCategory.find params[:category_id] + if params[:commit] == 'Update' + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + preload_object_auth_ary = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') + preload_object_auth = preload_object_auth_ary.first + preload_object_auth.privilege_users = privilege_users + preload_object_auth.save! + end + else + first_category = @bulletin_categorys.first + end + preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') + @users_array = preload_object_auth.first.privilege_users rescue [] + respond_to do |format| + format.html + format.js end end - def new + def update_setting end - - def create - + # def index + # get_categorys(params[:bulletin_category_id]) + # + # @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all + # @bulletin_categories = BulletinCategory.all + # + # module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) + # @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) + # + # respond_to do |format| + # format.html # index.html.erb + # format.js + # format.xml { render :xml => @bulletins } + # end + # end + # + # def new + # + # end + # + # def create + # + # end + # + # def update + # + # end + # + # def edit + # + # end + # + # def destroy + # + # end + protected + def get_categorys(id = nil) + @bulletin_categorys = [] + 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') + end end - - def update - - end - - def edit - - end - - def destroy - - end - end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 188142ead..e68e2c978 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -19,6 +19,9 @@ class Bulletin field :is_top, :type => Boolean, :default => false field :is_hot, :type => Boolean, :default => false field :is_hidden, :type => Boolean, :default => false + field :is_checked, :type => Boolean, :default => false + + field :not_checked_reason field :public, :type => Boolean, :default => true 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 3f6f50e1e..e12af233c 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 @@ -24,11 +24,12 @@ +
  • <%= link_to t('bulletin.fact_check'), edit_panel_announcement_back_end_bulletin_path(bulletin) %>
  • <%#= #TODO add ancher so user can quick access into that part %> <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> - <%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) %> + <%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%> <%= bulletin.postdate %> <%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %> @@ -36,7 +37,7 @@ <%= tag[I18n.locale] %> <% end %> - <%= User.from_id(bulletin.update_user_id).name %> + <%= User.from_id(bulletin.update_user_id).name rescue ''%> <%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %> 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 751a5f127..2236b5ede 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 @@ -2,7 +2,16 @@ <%= f.error_messages %> <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> - +
    + <%= label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %> + <%= f.radio_button :is_checked, true%> + <%= label :is_checked_true, t('announcement.bulletin.fact_check_pass') %> + <%= f.radio_button :is_checked, false, (@bulletin.is_checked.nil?? {:checked => true} : {}) %> + <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass') %> + + <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %> + <%= f.text_field :not_checked_reason %> +
    <%= f.label :image, t('announcement.image') %>
    <%= f.file_field :image %> @@ -523,6 +532,8 @@
    --> + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb index 91726d88d..96e8237cd 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb @@ -3,11 +3,11 @@ <%= t(:quick_edit) %> - Basic / Picture / Tags / Link / File <%= form_for bulletin, :url => panel_announcement_back_end_bulletin_path(bulletin), :html => {:class => 'form-horizontal'} do |f| %> - <%= render :partial => "quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_files", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_files", :locals => { :f => f, :bulletin => bulletin } %>
    <%= f.submit t(:submit), :class => 'btn btn-primary' %> <%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %> 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 fd2b29b5b..c833297af 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 @@ -2,7 +2,6 @@ <%= render 'bulletins' %>
    -
    <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb deleted file mode 100644 index 59bac03aa..000000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -

    <%= bulletin_category.key %>

    - - - - - - - - - - -<% bulletin_category.bulletins.each do |post| %> - <%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %> -<% end %> -
    <%= t('bulletin.status') %><%= t('bulletin.category') %><%= t('bulletin.title') %><%= t('bulletin.postdate') %><%= t('bulletin.deadline') %><%= t('bulletin.action') %>
    \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb deleted file mode 100644 index 6f878b068..000000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -<% content_for :secondary do %> -<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %> -<% end -%> - -<%= flash_messages %> - -
    -
    -
    -
    -
    - -
    <%= t('bulletin.search') %> - - <%= form_for :bulletin, :action => 'search', :method => 'get', :url => panel_announcement_back_end_bulletins_path do |f| %> - - <%#= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('bulletin.select') }%> - - Category <%#= select_tag "category_id", options_for_select(@bulletin_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('bulletin.select') %> - - KeyWord <%#= text_field_tag :search, params[:search], :id => 'search_field' %> - - <%= submit_tag "Search", :name => nil %> - - <% end %> - - -
    - -
    -
    - -

    <%= t('bulletin.list_announcement') %>

    - -
    -

    Check Please

    - <%= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%> -
    -
    - diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 1f544b289..6143b177e 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -35,6 +35,12 @@ en: list_lower: " list" title: Title postdate: Postdate + fact_check: Fact Check + fact_check_setting: Fact Check Setting + fact_check_stat: Fact Check Status + fact_check_not_pass: 'Not Pass' + fact_check_not_pass_reason: 'Reason' + fact_check_pass: 'Pass' # 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 a9da545bf..e2dfd9570 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -30,6 +30,13 @@ zh_tw: list_lower: 列表 title: 標題 postdate: 張貼日期 + fact_check: 公告審核 + fact_check_setting: 審核設定 + fact_check_stat: 審核狀況 + fact_check_not_pass: '不通過' + fact_check_pass: '通過' + fact_check_not_pass_reason: '不通過原因' + # admin: # action: 行動 # add_language: 新增語言 diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index cb39d2537..f6f30b310 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -3,8 +3,9 @@ Rails.application.routes.draw do namespace :announcement do namespace :back_end do match 'public' => "announcements#public",:as => :public - resources :fact_checks - match 'list_mine' => "announcements#list_mine" + match 'fact_check_setting' => "fact_checks#setting" ,:as => :fact_checks_setting + match 'update_setting' => "fact_checks#update_setting" ,:as => :fact_checks_update_setting + root :to => "bulletins#index" resources :bulletins resources :bulletin_categorys, :controller => 'bulletin_categorys' do