From a4b1681d396c0e6dc48ec0227f8fb6bcd280ec14 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 17 Jul 2012 10:21:46 +0800 Subject: [PATCH] fix rejection for announcement and news. --- .../back_end/approvals_controller.rb | 18 +++++++++-- .../back_end/bulletins_controller.rb | 14 ++++++--- .../announcement/back_end/bulletins_helper.rb | 2 +- .../announcement/app/models/bulletin.rb | 30 +++++++++++-------- .../approvals/_modal_approve.html.erb | 2 +- .../announcement/config/locales/zh_tw.yml | 2 ++ .../back_end/news_approvals_controller.rb | 14 ++++++++- .../news/back_end/news_bulletins_helper.rb | 2 +- .../news/app/models/news_bulletin.rb | 29 +++++++++++------- .../news_approvals/_modal_approve.html.erb | 2 +- .../news/config/locales/zh_tw.yml | 3 +- 11 files changed, 82 insertions(+), 36 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 8944f9bb..0246ab7c 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -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) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 7e346fd3..c20b24a7 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -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,10 +216,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| @@ -255,11 +256,16 @@ 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 diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb index 91147c62..3f57fd3a 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -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 diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index dea2fc17..a6b0e55f 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -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 diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb index 35049b98..2a400a1f 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb @@ -18,7 +18,7 @@