added get_categorywise_locations

This commit is contained in:
saurabhbhatia 2013-10-03 15:52:46 +08:00
parent ec6ef5a871
commit 746bcbed96
3 changed files with 24 additions and 1 deletions

View File

@ -38,7 +38,11 @@ class Panel::Location::BackEnd::LocationCategoriesController < OrbitBackendContr
@data = Array.new
location_categories.each do |category|
@data << { name: category.name }
I18n.locale = :en
name_en = category.name
I18n.locale = :zh_tw
name_zh_tw = category.name
@data << { name_en: name_en, name_zh_tw: name_zh_tw, category_id: category.id.to_s, location_link: "http://ntue.tp.rulingcom.com/panel/location/back_end/locations/get_categorywise_locations" }
end
render :json => JSON.pretty_generate({location_category: @data})

View File

@ -71,6 +71,24 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
description: location.description }
end
render :json => JSON.pretty_generate({location: @data})
end
def get_categorywise_locations
location_infos = LocationInfo.where(:location_category_id => params[:category_id])
@data = Array.new
location_infos.each do |location|
picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}"
thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}"
@data << { name: location.name,
pic_url: picurl,
thumb_url: thumburl,
longitude: location.longitude,
latitude: location.latitude,
description: location.description }
end
render :json => JSON.pretty_generate({location: @data})
end
end

View File

@ -4,6 +4,7 @@ Rails.application.routes.draw do
namespace :back_end do
match "locations/get_locations" => "locations#get_locations"
match "locations/get_categorywise_locations" => "locations#get_categorywise_locations"
resources :locations
resources :location_categories, :except => [:show]