fix rejection for announcement and news.
This commit is contained in:
parent
2ae6b54a45
commit
a4b1681d39
|
@ -7,9 +7,21 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
|
||||||
@bulletin = Bulletin.find params[:bulletin_id]
|
@bulletin = Bulletin.find params[:bulletin_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
# def approve
|
def approve
|
||||||
#
|
notice = ""
|
||||||
# end
|
@bulletin = Bulletin.find params[:bulletin_id]
|
||||||
|
|
||||||
|
@bulletin.is_checked = params[:bulletin][:is_checked]
|
||||||
|
@bulletin.not_checked_reason = params[:bulletin][:not_checked_reason]
|
||||||
|
@bulletin.de_pending
|
||||||
|
|
||||||
|
if @bulletin.save
|
||||||
|
notice = t('bulletin.approve_bulletin_success')
|
||||||
|
else
|
||||||
|
notice = t('bulletin.approve_bulletin_fail')
|
||||||
|
end
|
||||||
|
redirect_to(panel_announcement_back_end_bulletins_url,:notice => notice)
|
||||||
|
end
|
||||||
|
|
||||||
def setting
|
def setting
|
||||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
layout 'new_admin'
|
layout 'new_admin'
|
||||||
|
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :only => [ :new,:edit,:update] do |controller|
|
before_filter :only => [ :new,:create,:edit,:update] do |controller|
|
||||||
controller.get_categorys('BulletinCategory')
|
controller.get_categorys('BulletinCategory')
|
||||||
end
|
end
|
||||||
# before_filter :for_admin_only,:only => [:]
|
# before_filter :for_admin_only,:only => [:]
|
||||||
|
@ -113,7 +113,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# POST /bulletins
|
# POST /bulletins
|
||||||
# POST /bulletins.xml
|
# POST /bulletins.xml
|
||||||
def create
|
def create
|
||||||
|
get_tags
|
||||||
if params[:bulletin_link]
|
if params[:bulletin_link]
|
||||||
|
|
||||||
@bulletin_link = BulletinLink.new(params[:bulletin_link])
|
@bulletin_link = BulletinLink.new(params[:bulletin_link])
|
||||||
|
@ -216,6 +216,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# PUT /bulletins/1
|
# PUT /bulletins/1
|
||||||
# PUT /bulletins/1.xml
|
# PUT /bulletins/1.xml
|
||||||
def update
|
def update
|
||||||
|
|
||||||
if params[:bulletin_link]
|
if params[:bulletin_link]
|
||||||
|
|
||||||
@bulletin_link = BulletinLink.find(params[:id])
|
@bulletin_link = BulletinLink.find(params[:id])
|
||||||
|
@ -256,10 +257,15 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# params[:bulletin][:image_del] = nil
|
# params[:bulletin][:image_del] = nil
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
||||||
delete_out_invalid_date_from_params
|
delete_out_invalid_date_from_params
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
if @bulletin.update_attributes(params[:bulletin])
|
if @bulletin.update_attributes(params[:bulletin])
|
||||||
|
# if (params[:bulletin][:is_checked] == "false")
|
||||||
|
# @bulletin.is_rejected = true
|
||||||
|
# @bulletin.save!
|
||||||
|
# end
|
||||||
# if (@bulletin.deadline < @bulletin.postdate rescue nil)
|
# if (@bulletin.deadline < @bulletin.postdate rescue nil)
|
||||||
# @bulletin.deadline = nil
|
# @bulletin.deadline = nil
|
||||||
# @bulletin.update_user_id = current_user.id
|
# @bulletin.update_user_id = current_user.id
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Panel::Announcement::BackEnd::BulletinsHelper
|
module Panel::Announcement::BackEnd::BulletinsHelper
|
||||||
|
|
||||||
def show_approval_link(bulletin)
|
def show_approval_link(bulletin)
|
||||||
by_bulletin = (!bulletin.is_expired? and !bulletin.is_checked?)
|
by_bulletin = (!bulletin.is_expired? and bulletin.is_pending?)
|
||||||
by_user = ((bulletin.bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?)
|
by_user = ((bulletin.bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?)
|
||||||
by_bulletin and by_user
|
by_bulletin and by_user
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Bulletin
|
||||||
|
|
||||||
validates_presence_of :title
|
validates_presence_of :title
|
||||||
|
|
||||||
before_save :set_key, :update_status,:check_deadline
|
before_save :set_key,:check_deadline,:update_status
|
||||||
|
|
||||||
after_save :save_bulletin_links
|
after_save :save_bulletin_links
|
||||||
after_save :save_bulletin_files
|
after_save :save_bulletin_files
|
||||||
|
@ -73,6 +73,9 @@ class Bulletin
|
||||||
# # :limit => limit
|
# # :limit => limit
|
||||||
# # }
|
# # }
|
||||||
# }
|
# }
|
||||||
|
def de_pending
|
||||||
|
self.is_pending = false
|
||||||
|
end
|
||||||
|
|
||||||
def publish_month
|
def publish_month
|
||||||
published_at.strftime("%B %Y")
|
published_at.strftime("%B %Y")
|
||||||
|
@ -127,7 +130,7 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_checked?
|
def is_checked?
|
||||||
self.is_checked
|
!self.is_pending && self.is_checked && (self.is_rejected == false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_pending?
|
def is_pending?
|
||||||
|
@ -135,7 +138,7 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_rejected?
|
def is_rejected?
|
||||||
self.is_rejected
|
!self.is_pending && self.is_rejected && (self.is_rejected == true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,16 +204,19 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_status
|
def update_status
|
||||||
if !self.is_pending && !self.is_checked
|
if !self.is_pending
|
||||||
self.is_pending = false
|
if !self.is_checked
|
||||||
|
# self.is_pending = false
|
||||||
self.is_rejected = true
|
self.is_rejected = true
|
||||||
self.is_checked = false
|
#self.is_checked = false
|
||||||
elsif self.is_checked
|
elsif self.is_checked
|
||||||
self.is_pending = false
|
# self.is_pending = false
|
||||||
self.is_rejected = false
|
self.is_rejected = false
|
||||||
self.is_checked = true
|
#self.is_checked = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
||||||
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_path(bulletin), :html => {:class => 'clear'} do |f| %>
|
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'clear'} do |f| %>
|
||||||
<%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %>
|
<%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %>
|
||||||
<%= content_tag :label,:class => "radio inline" do -%>
|
<%= content_tag :label,:class => "radio inline" do -%>
|
||||||
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
|
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
|
||||||
|
|
|
@ -81,6 +81,8 @@ zh_tw:
|
||||||
edit: 編輯
|
edit: 編輯
|
||||||
update_bulletin_success: 成功更新公告
|
update_bulletin_success: 成功更新公告
|
||||||
create_bulletin_success: 成功新增公告
|
create_bulletin_success: 成功新增公告
|
||||||
|
approve_bulletin_success: 成功審核公告
|
||||||
|
approve_bulletin_fail: 審核公告失敗
|
||||||
# action: 行動
|
# action: 行動
|
||||||
# add_language: 新增語言
|
# add_language: 新增語言
|
||||||
# admin: 管理
|
# admin: 管理
|
||||||
|
|
|
@ -8,7 +8,19 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def approve
|
def approve
|
||||||
|
notice = ""
|
||||||
|
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
|
||||||
|
|
||||||
|
@news_bulletin.is_checked = params[:news_bulletin][:is_checked]
|
||||||
|
@news_bulletin.not_checked_reason = params[:news_bulletin][:not_checked_reason]
|
||||||
|
@news_bulletin.de_pending
|
||||||
|
|
||||||
|
if @news_bulletin.save
|
||||||
|
notice = t('news_bulletin.approve_bulletin_success')
|
||||||
|
else
|
||||||
|
notice = t('news_bulletin.approve_bulletin_fail')
|
||||||
|
end
|
||||||
|
redirect_to(panel_news_back_end_news_bulletins_url,:notice => notice)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setting
|
def setting
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Panel::News::BackEnd::NewsBulletinsHelper
|
module Panel::News::BackEnd::NewsBulletinsHelper
|
||||||
|
|
||||||
def news_show_approval_link(news_bulletin)
|
def news_show_approval_link(news_bulletin)
|
||||||
by_news_bulletin = (!news_bulletin.is_expired? and !news_bulletin.is_checked?)
|
by_news_bulletin = (!news_bulletin.is_expired? and news_bulletin.is_pending?)
|
||||||
by_user = (news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) or is_manager? or is_admin?)
|
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
|
by_news_bulletin and by_user
|
||||||
end
|
end
|
||||||
|
|
|
@ -132,6 +132,10 @@ class NewsBulletin
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def de_pending
|
||||||
|
self.is_pending = false
|
||||||
|
end
|
||||||
|
|
||||||
def is_expired?
|
def is_expired?
|
||||||
Date.today > self.deadline ? true : false rescue false
|
Date.today > self.deadline ? true : false rescue false
|
||||||
#some dates might sat as nil so rescue false
|
#some dates might sat as nil so rescue false
|
||||||
|
@ -150,7 +154,7 @@ class NewsBulletin
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_checked?
|
def is_checked?
|
||||||
self.is_checked
|
!self.is_pending && self.is_checked && (self.is_rejected == false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_pending?
|
def is_pending?
|
||||||
|
@ -158,10 +162,11 @@ class NewsBulletin
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_rejected?
|
def is_rejected?
|
||||||
self.is_rejected
|
!self.is_pending && self.is_rejected && (self.is_rejected == true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def save_news_bulletin_links
|
def save_news_bulletin_links
|
||||||
self.news_bulletin_links.each do |t|
|
self.news_bulletin_links.each do |t|
|
||||||
if t.should_destroy
|
if t.should_destroy
|
||||||
|
@ -217,16 +222,18 @@ class NewsBulletin
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_status
|
def update_status
|
||||||
if !self.is_pending && !self.is_checked
|
if !self.is_pending
|
||||||
self.is_pending = false
|
if !self.is_checked
|
||||||
|
# self.is_pending = false
|
||||||
self.is_rejected = true
|
self.is_rejected = true
|
||||||
self.is_checked = false
|
#self.is_checked = false
|
||||||
elsif self.is_checked
|
elsif self.is_checked
|
||||||
self.is_pending = false
|
# self.is_pending = false
|
||||||
self.is_rejected = false
|
self.is_rejected = false
|
||||||
self.is_checked = true
|
#self.is_checked = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
||||||
<%= form_for news_bulletin, :url => panel_news_back_end_news_bulletin_path(news_bulletin), :html => {:class => 'clear'} do |f| %>
|
<%= form_for news_bulletin, :url => panel_news_back_end_news_bulletin_approve_path(news_bulletin),:method => :post, :html => {:class => 'clear'} do |f| %>
|
||||||
<%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %>
|
<%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %>
|
||||||
<%= content_tag :label,:class => "radio inline" do -%>
|
<%= content_tag :label,:class => "radio inline" do -%>
|
||||||
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
|
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
|
||||||
|
|
|
@ -79,7 +79,8 @@ zh_tw:
|
||||||
update_failed: 分類更新失敗
|
update_failed: 分類更新失敗
|
||||||
create_news_bulletin_success: 新增新聞成功
|
create_news_bulletin_success: 新增新聞成功
|
||||||
update_success: 更新新聞成功
|
update_success: 更新新聞成功
|
||||||
|
approve_bulletin_success: 成功審核新聞
|
||||||
|
approve_bulletin_fail: 審核新聞失敗
|
||||||
# action: 行動
|
# action: 行動
|
||||||
# add_language: 新增語言
|
# add_language: 新增語言
|
||||||
# admin: 管理
|
# admin: 管理
|
||||||
|
|
Loading…
Reference in New Issue