about route url link bug

This commit is contained in:
Rueshyna 2012-11-14 16:20:32 +08:00
parent 96622b168f
commit 4b3911e866
4 changed files with 64 additions and 60 deletions

View File

@ -35,7 +35,6 @@ class Admin::UsersNewInterfaceController < ApplicationController
attribute_values = @user.attribute_values attribute_values = @user.attribute_values
attribute_values.each{|att_val| attribute_values.each{|att_val|
binding.pry if att_val.id.to_s == '5052dab52b5c49ae9d000006'
@profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false
} }

View File

@ -6,7 +6,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
@bulletin_categorys = get_categories_for_index("BulletinCategory") @bulletin_categorys = get_categories_for_index("BulletinCategory")
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好 #TODO 需要做 manager ,admin 才可以 all. 其他 available就好
@bulletin_category = BulletinCategory.new(:display => 'List') @bulletin_category = BulletinCategory.new(:display => 'List')
@url = panel_announcement_back_end_bulletin_categorys_path @url = panel_announcement_back_end_bulletin_categorys_path
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
@ -15,6 +15,47 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
end end
end end
def get_categorys_json
categorys = BulletinCategory.all
data = Array.new
categorys.each do |c|
data << {
category: c.title,
# link: get_bulletin_json(c)
}
end
#render :json => @data.to_json
#to print readable json
render :json => JSON.pretty_generate(data)
end
def get_bulletins_json
bulletin = Bulletin.where(params[:category_id])
data = Array.new
bulletin.each do |b|
deadline = b.deadline
if not deadline.nil?
deadline = display_date_time(deadline)
else
deadline = I18n.t("no_deadline")
end
data << {
title: b.title,
link: panel_announcement_front_end_bulletin_path(bulletin, :category_id => b.bulletin_category.id),
postdate: display_date_time(b.postdate),
deadline: deadline,
tag: b.sorted_tags.to_a,
}
end
render :json => JSON.pretty_generate(data)
end
# GET /bulletins/1 # GET /bulletins/1
# GET /bulletins/1.xml # GET /bulletins/1.xml
def show def show
@ -40,11 +81,11 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
end end
def quick_edit def quick_edit
# debugger # debugger
@bulletin_category = BulletinCategory.find(params[:bulletin_category_id]) @bulletin_category = BulletinCategory.find(params[:bulletin_category_id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category) @url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format| respond_to do |format|
format.js format.js
@ -56,7 +97,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
def edit def edit
@bulletin_category = BulletinCategory.find(params[:id]) @bulletin_category = BulletinCategory.find(params[:id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category) @url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format| respond_to do |format|
format.html format.html
@ -88,7 +129,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
def update def update
@bulletin_category = BulletinCategory.find(params[:id]) @bulletin_category = BulletinCategory.find(params[:id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category) @url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format| respond_to do |format|
if @bulletin_category.update_attributes(params[:bulletin_category]) if @bulletin_category.update_attributes(params[:bulletin_category])

View File

@ -7,8 +7,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# before_filter :for_admin_only,:only => [:] # before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,] # 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_visitor,:only=>[: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 :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins,:get_bulletins_json,:get_bulletin_json]
before_filter :for_app_sub_manager,: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,:get_bulletin_json]
before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| before_filter :only => [ :new,:create,:edit,:update,:create] do |controller|
controller.get_categorys('BulletinCategory') controller.get_categorys('BulletinCategory')
@ -22,46 +22,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
render '/shared/preview/preview.html.erb',:layout=>false render '/shared/preview/preview.html.erb',:layout=>false
end end
def get_bulletins_json
categorys = BulletinCategory.all
data = Array.new
categorys.each do |c|
data << {
category: c.title
link: path_get_bulletin_json(c)
}
end
#render :json => @data.to_json
#to print readable json
render :json => JSON.pretty_generate(@data)
end
def get_bulletin_json
bulletin = Bulletin.find(params[:category_id])
data = Array.new
bulletin.each do |b|
deadline = b.deadline
if not deadline.nil?
deadline = display_date_time(deadline)
else
deadline = I18n.t("no_deadline")
end
data << {
title: b.title,
link: panel_announcement_front_end_bulletin_path(bulletin, :category_id => b.bulletin_category.id)
postdate: display_date_time(b.postdate),
deadline: deadline,
tag: b.sorted_tags.to_a,
}
end
render :json => JSON.pretty_generate(data)
end
def index def index
# @bulletins = Bulletin.all # @bulletins = Bulletin.all

View File

@ -12,7 +12,7 @@ Rails.application.routes.draw do
match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post
match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit
match 'get_bulletin_json/:category_id' => "bulletins#get_bulletin_json", :as => :get_bulletin_json
member do member do
get 'load_quick_edit' get 'load_quick_edit'
end end
@ -20,13 +20,17 @@ Rails.application.routes.draw do
post "preview" post "preview"
put "preview" put "preview"
get 'delete' get 'delete'
get 'get_bulletins_json'
end end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add 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 match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
end end
resources :bulletin_categorys resources :bulletin_categorys do
collection do
get 'get_categorys_json'
end
match "get_bulletins_json/" => "bulletin_categorys#get_bulletins_json", :as => :get_bulletins_json
end
resources :bulletin_links, :controller => 'bulletin_links' do resources :bulletin_links, :controller => 'bulletin_links' do
match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit