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]
|
||||
end
|
||||
|
||||
# def approve
|
||||
#
|
||||
# end
|
||||
def approve
|
||||
notice = ""
|
||||
@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
|
||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||
|
|
|
@ -5,7 +5,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
layout 'new_admin'
|
||||
|
||||
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')
|
||||
end
|
||||
# before_filter :for_admin_only,:only => [:]
|
||||
|
@ -113,7 +113,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
# POST /bulletins
|
||||
# POST /bulletins.xml
|
||||
def create
|
||||
|
||||
get_tags
|
||||
if 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.xml
|
||||
def update
|
||||
|
||||
if params[:bulletin_link]
|
||||
|
||||
@bulletin_link = BulletinLink.find(params[:id])
|
||||
|
@ -256,10 +257,15 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
# params[:bulletin][:image_del] = nil
|
||||
# end
|
||||
|
||||
|
||||
delete_out_invalid_date_from_params
|
||||
respond_to do |format|
|
||||
|
||||
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)
|
||||
# @bulletin.deadline = nil
|
||||
# @bulletin.update_user_id = current_user.id
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Panel::Announcement::BackEnd::BulletinsHelper
|
||||
|
||||
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_bulletin and by_user
|
||||
end
|
||||
|
|
|
@ -57,7 +57,7 @@ class Bulletin
|
|||
|
||||
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_files
|
||||
|
@ -73,6 +73,9 @@ class Bulletin
|
|||
# # :limit => limit
|
||||
# # }
|
||||
# }
|
||||
def de_pending
|
||||
self.is_pending = false
|
||||
end
|
||||
|
||||
def publish_month
|
||||
published_at.strftime("%B %Y")
|
||||
|
@ -127,7 +130,7 @@ end
|
|||
end
|
||||
|
||||
def is_checked?
|
||||
self.is_checked
|
||||
!self.is_pending && self.is_checked && (self.is_rejected == false)
|
||||
end
|
||||
|
||||
def is_pending?
|
||||
|
@ -135,7 +138,7 @@ end
|
|||
end
|
||||
|
||||
def is_rejected?
|
||||
self.is_rejected
|
||||
!self.is_pending && self.is_rejected && (self.is_rejected == true)
|
||||
end
|
||||
|
||||
|
||||
|
@ -201,15 +204,18 @@ end
|
|||
end
|
||||
|
||||
def update_status
|
||||
if !self.is_pending && !self.is_checked
|
||||
self.is_pending = false
|
||||
self.is_rejected = true
|
||||
self.is_checked = false
|
||||
elsif self.is_checked
|
||||
self.is_pending = false
|
||||
self.is_rejected = false
|
||||
self.is_checked = true
|
||||
if !self.is_pending
|
||||
if !self.is_checked
|
||||
# self.is_pending = false
|
||||
self.is_rejected = true
|
||||
#self.is_checked = false
|
||||
elsif self.is_checked
|
||||
# self.is_pending = false
|
||||
self.is_rejected = false
|
||||
#self.is_checked = true
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
</div>
|
||||
<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') %>
|
||||
<%= content_tag :label,:class => "radio inline" do -%>
|
||||
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
|
||||
|
|
|
@ -81,6 +81,8 @@ zh_tw:
|
|||
edit: 編輯
|
||||
update_bulletin_success: 成功更新公告
|
||||
create_bulletin_success: 成功新增公告
|
||||
approve_bulletin_success: 成功審核公告
|
||||
approve_bulletin_fail: 審核公告失敗
|
||||
# action: 行動
|
||||
# add_language: 新增語言
|
||||
# admin: 管理
|
||||
|
|
|
@ -8,7 +8,19 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def setting
|
||||
|
|
|
@ -1,7 +1,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_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_news_bulletin and by_user
|
||||
end
|
||||
|
|
|
@ -132,6 +132,10 @@ class NewsBulletin
|
|||
|
||||
end
|
||||
|
||||
def de_pending
|
||||
self.is_pending = false
|
||||
end
|
||||
|
||||
def is_expired?
|
||||
Date.today > self.deadline ? true : false rescue false
|
||||
#some dates might sat as nil so rescue false
|
||||
|
@ -150,7 +154,7 @@ class NewsBulletin
|
|||
end
|
||||
|
||||
def is_checked?
|
||||
self.is_checked
|
||||
!self.is_pending && self.is_checked && (self.is_rejected == false)
|
||||
end
|
||||
|
||||
def is_pending?
|
||||
|
@ -158,10 +162,11 @@ class NewsBulletin
|
|||
end
|
||||
|
||||
def is_rejected?
|
||||
self.is_rejected
|
||||
!self.is_pending && self.is_rejected && (self.is_rejected == true)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def save_news_bulletin_links
|
||||
self.news_bulletin_links.each do |t|
|
||||
if t.should_destroy
|
||||
|
@ -217,16 +222,18 @@ class NewsBulletin
|
|||
end
|
||||
|
||||
def update_status
|
||||
if !self.is_pending && !self.is_checked
|
||||
self.is_pending = false
|
||||
self.is_rejected = true
|
||||
self.is_checked = false
|
||||
elsif self.is_checked
|
||||
self.is_pending = false
|
||||
self.is_rejected = false
|
||||
self.is_checked = true
|
||||
if !self.is_pending
|
||||
if !self.is_checked
|
||||
# self.is_pending = false
|
||||
self.is_rejected = true
|
||||
#self.is_checked = false
|
||||
elsif self.is_checked
|
||||
# self.is_pending = false
|
||||
self.is_rejected = false
|
||||
#self.is_checked = true
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -18,7 +18,7 @@
|
|||
</div>
|
||||
<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') %>
|
||||
<%= content_tag :label,:class => "radio inline" do -%>
|
||||
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
|
||||
|
|
|
@ -79,7 +79,8 @@ zh_tw:
|
|||
update_failed: 分類更新失敗
|
||||
create_news_bulletin_success: 新增新聞成功
|
||||
update_success: 更新新聞成功
|
||||
|
||||
approve_bulletin_success: 成功審核新聞
|
||||
approve_bulletin_fail: 審核新聞失敗
|
||||
# action: 行動
|
||||
# add_language: 新增語言
|
||||
# admin: 管理
|
||||
|
|
Loading…
Reference in New Issue