add get_bulletins_json function

This commit is contained in:
Rueshyna 2012-11-08 15:56:14 +08:00
parent e6a9555dd8
commit 800279ea69
2 changed files with 175 additions and 160 deletions

View File

@ -4,11 +4,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
before_filter :clean_values, :only => [:create, :update]
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins,:get_bulletins_json]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins,:get_bulletins_json]
before_filter :only => [ :new,:create,:edit,:update,:create] do |controller|
controller.get_categorys('BulletinCategory')
@ -22,6 +22,28 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
render '/shared/preview/preview.html.erb',:layout=>false
end
def get_bulletins_json
@bulletins = Bulletin.all
@data = Hash.new
@data[I18n.t("category")] = Hash.new
@bulletins.each do |b|
deadline = b.deadline
if not deadline.nil?
deadline = display_date_time(deadline)
else
deadline = I18n.t("no_deadline")
end
@data[I18n.t("category")][b.bulletin_category.title] = { title: b.title,
postdate: display_date_time(b.postdate),
deadline: deadline,
tag: b.sorted_tags.to_a,
}
end
render :json => @data.to_json
end
def index
# @bulletins = Bulletin.all
# @bulletins = Bulletin.desc("postdate desc")
@ -165,9 +187,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
}
end
end
end
end
def link_quick_add
@ -178,7 +198,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
respond_to do |format|
format.js
end
end
def link_quick_edit
@ -196,7 +215,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
respond_to do |format|
format.js
end
end
def file_quick_edit
@ -214,11 +232,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
if params[:bulletin_link]
@bulletin_link = BulletinLink.find(params[:id])
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
respond_to do |format|
if @bulletin_link.update_attributes(params[:bulletin_link])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_bulletin_link' }
@ -228,9 +244,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.find(params[:id])
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format|
if @bulletin_file.update_attributes(params[:bulletin_file])
@ -377,5 +391,4 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end rescue nil
end
end
end

View File

@ -6,6 +6,7 @@ Rails.application.routes.draw do
match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
#match 'get_bulletins_json' => "bulletins#get_bulletins_json" ,:as => :bulletins_json_list,:via => :get
resources :bulletins do
match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post
@ -18,6 +19,7 @@ Rails.application.routes.draw do
post "preview"
put "preview"
get 'delete'
get 'get_bulletins_json'
end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit