all of user can get json of gprs from outside

This commit is contained in:
Rueshyna 2012-11-08 01:24:37 +08:00
parent b4f5a0b04b
commit 11fefa100f
1 changed files with 68 additions and 24 deletions

View File

@ -1,14 +1,57 @@
class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
before_filter :clean_values, :only => [:create, :update]
before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
before_filter :force_order_for_user,:except => :get_locations
before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations]
def index def index
@newlocation = Location.new @locations = Location.all
respond_to do |format|
format.html # new.html.erb
format.json { render json: @locations }
end
end
def new
@location = Location.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @location }
end
end
def edit
@location = Location.find(params[:id])
end
def show
@location = Location..find(params[:id])
respond_to do |format|
format.html
format.json { render json: @location }
end
end end
def create def create
debugger debugger
@newlocation = Location.new(params[:location]) @location = Location.new(params[:location])
@newlocation.save! if @location.save
render :action => "index" format.html { redirect_to @location }
format.json { render json: @location, status: :created, location: @location }
end
#render :action => "new"
end
def destroy
@location = Location..find(params[:id])
@location.destroy
respond_to do |format|
format.json { head :no_content }
end
end end
def get_locations def get_locations
@ -18,12 +61,13 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
locations.each do |location| locations.each do |location|
picurl = "http://"+request.host + location.file.url picurl = "http://"+request.host + location.file.url
thumburl = "http://"+request.host + location.file.thumb.url thumburl = "http://"+request.host + location.file.thumb.url
@data << {"name"=>location.name,"pic_url"=>picurl,"thumb_url"=>thumburl,"description"=>location.description} @data << { name: location.name,
pic_url: picurl,
thumb_url: thumburl,
longitude: location.longitude,
latitude: location.latitude,
description: location.description }
end end
render :json => @data.to_json render :json => @data.to_json
end end
end end