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,29 +1,73 @@
class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
def index
@newlocation = Location.new
end
def create before_filter :clean_values, :only => [:create, :update]
debugger
@newlocation = Location.new(params[:location])
@newlocation.save!
render :action => "index"
end
def get_locations before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
locations = Location.all before_filter :force_order_for_user,:except => :get_locations
@data = Array.new before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations]
locations.each do |location| def index
picurl = "http://"+request.host + location.file.url @locations = Location.all
thumburl = "http://"+request.host + location.file.thumb.url respond_to do |format|
@data << {"name"=>location.name,"pic_url"=>picurl,"thumb_url"=>thumburl,"description"=>location.description} format.html # new.html.erb
end format.json { render json: @locations }
render :json => @data.to_json end
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
def create
debugger
@location = Location.new(params[:location])
if @location.save
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
def get_locations
locations = Location.all
@data = Array.new
locations.each do |location|
picurl = "http://"+request.host + location.file.url
thumburl = "http://"+request.host + 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 => @data.to_json
end
end end