fix rejection for announcement and news.

This commit is contained in:
Matthew K. Fu JuYuan 2012-07-17 10:21:46 +08:00
parent 85d6bbe1c9
commit a7b92ed3e8
11 changed files with 82 additions and 36 deletions

View File

@ -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)

View File

@ -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])
@ -215,10 +215,11 @@ 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])
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
respond_to do |format|
@ -252,10 +253,15 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# @bulletin.image_del = nil
# 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

View File

@ -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

View File

@ -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")
@ -125,9 +128,9 @@ end
def is_hidden?
self.is_hidden
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

View File

@ -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'} %>

View File

@ -81,6 +81,8 @@ zh_tw:
edit: 編輯
update_bulletin_success: 成功更新公告
create_bulletin_success: 成功新增公告
approve_bulletin_success: 成功審核公告
approve_bulletin_fail: 審核公告失敗
# action: 行動
# add_language: 新增語言
# admin: 管理

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'} %>

View File

@ -79,7 +79,8 @@ zh_tw:
update_failed: 分類更新失敗
create_news_bulletin_success: 新增新聞成功
update_success: 更新新聞成功
approve_bulletin_success: 成功審核新聞
approve_bulletin_fail: 審核新聞失敗
# action: 行動
# add_language: 新增語言
# admin: 管理