From 746bcbed966fa024951385c870d47a0ae30af4c7 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Thu, 3 Oct 2013 15:52:46 +0800 Subject: [PATCH] added get_categorywise_locations --- .../back_end/location_categories_controller.rb | 6 +++++- .../location/back_end/locations_controller.rb | 18 ++++++++++++++++++ .../built_in_modules/location/config/routes.rb | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb index d2e488aab..950ebbe25 100644 --- a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb +++ b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/location_categories_controller.rb @@ -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}) diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb index 7754835a6..d744ea721 100644 --- a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb +++ b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb @@ -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 diff --git a/vendor/built_in_modules/location/config/routes.rb b/vendor/built_in_modules/location/config/routes.rb index acd4616f2..1137ee44e 100644 --- a/vendor/built_in_modules/location/config/routes.rb +++ b/vendor/built_in_modules/location/config/routes.rb @@ -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]