Fact check program completed,Lin checked
This commit is contained in:
parent
7cc075e124
commit
34a4e47057
|
@ -41,6 +41,7 @@ GEM
|
||||||
archive-tar-minitar (0.5.2)
|
archive-tar-minitar (0.5.2)
|
||||||
arel (2.2.3)
|
arel (2.2.3)
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
|
bcrypt-ruby (3.0.1-x86-mingw32)
|
||||||
brakeman (1.5.1)
|
brakeman (1.5.1)
|
||||||
activesupport
|
activesupport
|
||||||
erubis (~> 2.6)
|
erubis (~> 2.6)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class ObjectAuth < PrototypeAuth
|
class ObjectAuth < PrototypeAuth
|
||||||
include OrbitCoreLib::ObjectTokenUnility
|
include OrbitCoreLib::ObjectTokenUnility
|
||||||
validates_uniqueness_of :obj_authable_type,:scope => :title #{ |c| }
|
validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| }
|
||||||
belongs_to :obj_authable, polymorphic: true
|
belongs_to :obj_authable, polymorphic: true
|
||||||
# > - Something.find_with_auth(query)
|
# > - Something.find_with_auth(query)
|
||||||
# > - or Something.find(query).auth
|
# > - or Something.find(query).auth
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
<%= 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.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.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('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') %>
|
<%= 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') if is_manager? %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%= content_tag :li, :class => active_for_controllers('users') do -%>
|
<%= content_tag :li, :class => active_for_controllers('users') do -%>
|
||||||
|
|
|
@ -21,11 +21,19 @@ module OrbitCoreLib
|
||||||
|
|
||||||
def authed_users(title=nil)
|
def authed_users(title=nil)
|
||||||
users = []
|
users = []
|
||||||
unless title.nil?
|
users = case title
|
||||||
users = self.object_auths.where(title: title )[0].auth_users_after_block_list rescue []
|
when :all
|
||||||
|
ary = self.object_auths.collect{|t| t.auth_users}
|
||||||
|
ary.flatten!
|
||||||
|
when nil
|
||||||
|
if self.object_auths.count ==1
|
||||||
|
self.object_auths.first.auth_users_after_block_list rescue []
|
||||||
else
|
else
|
||||||
users = self.object_auths.collect{|t| t.auth_users_after_block_list} rescue []
|
logger.info "Warning calling a auth commend without specificed value( has multi-auths ), return empty"
|
||||||
users.flatten!.uniq!
|
[]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.object_auths.where(title: title).first.auth_users rescue []
|
||||||
end
|
end
|
||||||
users
|
users
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationController
|
class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController
|
||||||
|
|
||||||
layout 'new_admin'
|
layout 'new_admin'
|
||||||
|
|
||||||
|
|
|
@ -110,22 +110,20 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
|
|
||||||
def link_quick_edit
|
def link_quick_edit
|
||||||
# debugger
|
# debugger
|
||||||
|
|
||||||
@bulletin = Bulletin.find(params[:bulletin_id])
|
@bulletin = Bulletin.find(params[:bulletin_id])
|
||||||
|
unless @bulletin.is_expired?
|
||||||
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
|
@link_url = panel_announcement_back_end_bulletin_path(@bulletin)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /bulletins/1
|
# PUT /bulletins/1
|
||||||
# PUT /bulletins/1.xml
|
# PUT /bulletins/1.xml
|
||||||
def update
|
def update
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.find(params[:id])
|
||||||
|
unless @bulletin.is_expired?
|
||||||
@bulletin.update_user_id = current_user.id
|
@bulletin.update_user_id = current_user.id
|
||||||
|
|
||||||
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
|
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
|
||||||
|
@ -147,6 +145,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# DELETE /bulletins/1
|
# DELETE /bulletins/1
|
||||||
# DELETE /bulletins/1.xml
|
# DELETE /bulletins/1.xml
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendControll
|
||||||
else
|
else
|
||||||
first_category = @bulletin_categorys.first
|
first_category = @bulletin_categorys.first
|
||||||
end
|
end
|
||||||
preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check')
|
preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check')
|
||||||
@users_array = preload_object_auth.first.privilege_users rescue []
|
@users_array = preload_object_auth.first.privilege_users rescue []
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|
|
@ -12,9 +12,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
|
|
||||||
date_now = Time.now
|
date_now = Time.now
|
||||||
if params[:category_id]
|
if params[:category_id]
|
||||||
@bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||||
else
|
else
|
||||||
@bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
get_categorys
|
get_categorys
|
||||||
|
@ -23,7 +23,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.can_display.where.where(_id: params[:id])
|
||||||
get_categorys
|
get_categorys
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
||||||
# @bulletin_categorys = BulletinCategory.first;
|
# @bulletin_categorys = BulletinCategory.first;
|
||||||
# @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
|
# @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
|
||||||
if params[:category_id]
|
if params[:category_id]
|
||||||
@bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
|
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
|
||||||
else
|
else
|
||||||
@bulletins = Bulletin.widget_datas.limit(9)
|
@bulletins = Bulletin.can_display.widget_datas.limit(9)
|
||||||
end
|
end
|
||||||
|
|
||||||
get_categorys
|
get_categorys
|
||||||
|
@ -26,14 +26,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
||||||
def bulletins_and_web_links
|
def bulletins_and_web_links
|
||||||
@tags = AnnouncementTag.all
|
@tags = AnnouncementTag.all
|
||||||
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
|
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
|
||||||
@bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
|
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
|
||||||
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
|
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
|
||||||
render :layout => 'module_widget'
|
render :layout => 'module_widget'
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload_bulletins
|
def reload_bulletins
|
||||||
@selected_tag = AnnouncementTag.find(params[:tag_id])
|
@selected_tag = AnnouncementTag.find(params[:tag_id])
|
||||||
@bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
|
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload_web_links
|
def reload_web_links
|
||||||
|
|
|
@ -19,12 +19,14 @@ class Bulletin
|
||||||
field :is_top, :type => Boolean, :default => false
|
field :is_top, :type => Boolean, :default => false
|
||||||
field :is_hot, :type => Boolean, :default => false
|
field :is_hot, :type => Boolean, :default => false
|
||||||
field :is_hidden, :type => Boolean, :default => false
|
field :is_hidden, :type => Boolean, :default => false
|
||||||
field :is_checked, :type => Boolean, :default => false
|
field :is_checked, :type => Boolean, :default => nil
|
||||||
|
|
||||||
field :not_checked_reason
|
field :not_checked_reason
|
||||||
|
|
||||||
field :public, :type => Boolean, :default => true
|
field :public, :type => Boolean, :default => true
|
||||||
|
|
||||||
|
scope :can_display,where(is_checked: true)
|
||||||
|
|
||||||
mount_uploader :image, ImageUploader
|
mount_uploader :image, ImageUploader
|
||||||
|
|
||||||
belongs_to :bulletin_category
|
belongs_to :bulletin_category
|
||||||
|
@ -47,28 +49,17 @@ class Bulletin
|
||||||
|
|
||||||
|
|
||||||
def self.search( search = nil, category_id = nil )
|
def self.search( search = nil, category_id = nil )
|
||||||
|
|
||||||
if category_id.to_s.size > 0 and search.to_s.size > 0
|
if category_id.to_s.size > 0 and search.to_s.size > 0
|
||||||
|
|
||||||
key = /#{search}/
|
key = /#{search}/
|
||||||
|
|
||||||
find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
|
find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
|
||||||
|
|
||||||
elsif category_id.to_s.size > 0 and search.to_s.size < 1
|
elsif category_id.to_s.size > 0 and search.to_s.size < 1
|
||||||
|
|
||||||
find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
|
find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
|
||||||
|
|
||||||
elsif search.to_s.size > 0 and category_id.to_s.size < 1
|
elsif search.to_s.size > 0 and category_id.to_s.size < 1
|
||||||
|
|
||||||
key = /#{search}/
|
key = /#{search}/
|
||||||
|
|
||||||
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
|
find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
|
||||||
else
|
else
|
||||||
|
|
||||||
find(:all).desc( :is_top, :postdate)
|
find(:all).desc( :is_top, :postdate)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,6 +79,10 @@ class Bulletin
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_expired?
|
||||||
|
Date.today > self.deadline ? true : false rescue false
|
||||||
|
#some dates might sat as nil so rescue false
|
||||||
|
end
|
||||||
|
|
||||||
def is_top?
|
def is_top?
|
||||||
self.is_top
|
self.is_top
|
||||||
|
@ -101,6 +96,15 @@ class Bulletin
|
||||||
self.is_hidden
|
self.is_hidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_checked?
|
||||||
|
self.is_checked
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_check_rejected?
|
||||||
|
self.is_checked == false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def save_bulletin_links
|
def save_bulletin_links
|
||||||
self.bulletin_links.each do |t|
|
self.bulletin_links.each do |t|
|
||||||
if t.should_destroy
|
if t.should_destroy
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
<% if bulletin.is_hidden? %>
|
<% if bulletin.is_hidden? %>
|
||||||
<span class="label"><%= t(:hidden) %></span>
|
<span class="label"><%= t(:hidden) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
<ul class="nav nav-pills hide">
|
<ul class="nav nav-pills hide">
|
||||||
|
<% unless bulletin.is_check_rejected?%>
|
||||||
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
|
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
|
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
|
||||||
|
@ -23,10 +25,16 @@
|
||||||
<li><a href="#" class='toggle-tr-edit' rel='file'><%= t(:file) %></a></li>
|
<li><a href="#" class='toggle-tr-edit' rel='file'><%= t(:file) %></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</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>
|
<%#= debugger %>
|
||||||
|
<%#= a=1 %>
|
||||||
|
<% if (bulletin.bulletin_category.authed_users('fact_check').include?(current_user) or is_manager?) and !bulletin.is_expired? %>
|
||||||
<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 %>
|
<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 %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
|
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
|
||||||
<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%></td>
|
<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%></td>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<% # encoding: utf-8 %>
|
<% # encoding: utf-8 %>
|
||||||
|
|
||||||
|
|
||||||
<%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %>
|
<%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %>
|
||||||
|
|
||||||
<div id="modal-link" class="modal hide fade">
|
<div id="modal-link" class="modal hide fade">
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
<%= f.error_messages %>
|
<%= f.error_messages %>
|
||||||
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
|
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
|
||||||
|
|
||||||
|
<% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin?%>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %>
|
<%= label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %>
|
||||||
<%= f.radio_button :is_checked, true%>
|
<%= f.radio_button :is_checked, true%>
|
||||||
|
@ -12,6 +14,8 @@
|
||||||
<%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %>
|
<%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %>
|
||||||
<%= f.text_field :not_checked_reason %>
|
<%= f.text_field :not_checked_reason %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= f.label :image, t('announcement.image') %><br />
|
<%= f.label :image, t('announcement.image') %><br />
|
||||||
<%= f.file_field :image %>
|
<%= f.file_field :image %>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<% # encoding: utf-8 %>
|
<% # encoding: utf-8 %>
|
||||||
|
|
||||||
<% if @bulletins and !@bulletins.nil? %>
|
<% if @bulletins and !@bulletins.nil? %>
|
||||||
|
|
||||||
<h2 class="topic_title"><%= t('announcement.campus_news')%></h2>
|
<h2 class="topic_title"><%= t('announcement.campus_news')%></h2>
|
||||||
<%= link_to t('announcement.more'),panel_announcement_front_end_bulletins_path(), :class => "topic_note" %>
|
<%= link_to t('announcement.more'),panel_announcement_front_end_bulletins_path(), :class => "topic_note" %>
|
||||||
<div class="topic_prev">previous page</div>
|
<div class="topic_prev">previous page</div>
|
||||||
|
|
Reference in New Issue