From ec6ef5a871e3858b57cdc294dbfb96cb3865172c Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Thu, 3 Oct 2013 15:06:59 +0800 Subject: [PATCH] NTUE localtion categories as json for Android App --- .../panel/gallery/front_end/albums_controller.rb | 3 +++ .../back_end/location_categories_controller.rb | 11 +++++++++++ vendor/built_in_modules/location/config/routes.rb | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb index b4ab266cc..5b8668d77 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb @@ -5,6 +5,9 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController def show @album = GalleryAlbum.find(params[:id]) @tags = Tag.find(@album.tagged_ids).map{|t| t.name} + respond_to do |format| + format.json { render json: @album } + end end def get_albums 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 07911caa2..d2e488aab 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 @@ -33,4 +33,15 @@ class Panel::Location::BackEnd::LocationCategoriesController < OrbitBackendContr render :json=>{"success"=>"true"}.to_json end + def get_location_categories + location_categories = LocationCategory.all + @data = Array.new + + location_categories.each do |category| + @data << { name: category.name } + end + + render :json => JSON.pretty_generate({location_category: @data}) + end + end \ No newline at end of file diff --git a/vendor/built_in_modules/location/config/routes.rb b/vendor/built_in_modules/location/config/routes.rb index d65c5b2ef..acd4616f2 100644 --- a/vendor/built_in_modules/location/config/routes.rb +++ b/vendor/built_in_modules/location/config/routes.rb @@ -6,7 +6,9 @@ Rails.application.routes.draw do match "locations/get_locations" => "locations#get_locations" resources :locations - resources :location_categories + resources :location_categories, :except => [:show] + match "location_categories/get_location_categories" => "location_categories#get_location_categories" + end end end