code for new fact check
This commit is contained in:
		
							parent
							
								
									db9608d918
								
							
						
					
					
						commit
						13b6892f87
					
				|  | @ -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' | ||||
|    | ||||
|  |  | |||
|  | @ -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 -%> | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
|  | @ -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 | ||||
|    | ||||
|    | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|    | ||||
|  |  | |||
|  | @ -24,11 +24,12 @@ | |||
| 					</ul> | ||||
| 				</li> | ||||
| 				<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li> | ||||
| 				<li><%= link_to t('bulletin.fact_check'), edit_panel_announcement_back_end_bulletin_path(bulletin)   %></li><%#= #TODO add ancher so user can quick access into that part %> | ||||
| 			</ul> | ||||
| 		</div> | ||||
| 	</td> | ||||
| 	<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td> | ||||
| 	<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) %></td> | ||||
| 	<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%></td> | ||||
| 	<td><%= bulletin.postdate %></td> | ||||
| 	<td><%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %></td> | ||||
| 	<td> | ||||
|  | @ -36,7 +37,7 @@ | |||
| 			<span class="label label-tags"><%= tag[I18n.locale] %></span> | ||||
| 		<% end %> | ||||
| 	</td> | ||||
| 	<td><%= User.from_id(bulletin.update_user_id).name %></td> | ||||
| 	<td><%= User.from_id(bulletin.update_user_id).name rescue ''%></td> | ||||
| </tr> | ||||
| 
 | ||||
| <%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %> | ||||
|  |  | |||
|  | @ -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" %> | ||||
| 
 | ||||
| 	<div class="field"> | ||||
| 		<%= 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 %> | ||||
| 	</div> | ||||
|   <div class="field"> | ||||
|     <%= f.label :image, t('announcement.image') %><br /> | ||||
|     <%= f.file_field :image %> | ||||
|  | @ -523,6 +532,8 @@ | |||
|         </div> | ||||
|     </div> | ||||
| </div> --> | ||||
| 
 | ||||
| 
 | ||||
| <!--Post End--> | ||||
| <!-- <div class="form-actions"> --> | ||||
|   <button class="btn btn-success" type="submit">Preview/預覽</button> | ||||
|  |  | |||
|  | @ -3,11 +3,11 @@ | |||
| 	<td colspan="8"> | ||||
| 		<legend><%= t(:quick_edit) %> - <span class='qe_title'></span>Basic / Picture / Tags / Link / File</legend> | ||||
| 		<%= 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 } %> | ||||
| 			<div class="form-actions"> | ||||
| 				<%= f.submit t(:submit), :class => 'btn btn-primary' %> | ||||
| 				<%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %> | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
| <table id="bulettin_sort_list" class="table main-list"> | ||||
| 	<%= render 'bulletins' %> | ||||
| </table> | ||||
| 
 | ||||
| <div class="form-actions"> | ||||
| 	<%= 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' %> | ||||
| </div> | ||||
|  |  | |||
|  | @ -1,15 +0,0 @@ | |||
| <h1><%= bulletin_category.key %></h1> | ||||
| <table> | ||||
|   <tr> | ||||
| 	<th><%= t('bulletin.status') %></th> | ||||
| 	<th><%= t('bulletin.category') %></th> | ||||
| 	<th><%= t('bulletin.title') %></th> | ||||
| 	<th><%= t('bulletin.postdate') %></th> | ||||
| 	<th><%= t('bulletin.deadline') %></th> | ||||
| 	<th><%= t('bulletin.action') %></th> | ||||
|   </tr> | ||||
| 
 | ||||
| <% bulletin_category.bulletins.each do |post| %> | ||||
| 	<%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %> | ||||
| <% end %>	 | ||||
| </table> | ||||
|  | @ -1,40 +0,0 @@ | |||
| <% content_for :secondary do %> | ||||
| <%= render :partial => '/panel/announcement/back_end/announcement_secondary' %> | ||||
| <% end -%> | ||||
| 
 | ||||
| <%= flash_messages %> | ||||
| 
 | ||||
| <br /> | ||||
| <br /> | ||||
| <br /> | ||||
| <br /> | ||||
| <br /> | ||||
|    | ||||
|   <fieldset><legend><%= t('bulletin.search') %></legend>	 | ||||
| 
 | ||||
|   <%= 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 %> | ||||
| 
 | ||||
|    | ||||
|   </fieldset> | ||||
| 
 | ||||
| <br /> | ||||
| <br /> | ||||
| 
 | ||||
| <h1><%= t('bulletin.list_announcement') %></h1> | ||||
| 
 | ||||
| <div id="check_block">	 | ||||
| 	<h1>Check Please</h1> | ||||
| 	<%= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%> | ||||
| </div> | ||||
| <br /> | ||||
| 
 | ||||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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: 新增語言 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
		Reference in New Issue