all of user can get json of gprs from outside
This commit is contained in:
parent
b4f5a0b04b
commit
11fefa100f
|
@ -1,14 +1,57 @@
|
|||
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
|
||||
@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
|
||||
|
||||
def create
|
||||
debugger
|
||||
@newlocation = Location.new(params[:location])
|
||||
@newlocation.save!
|
||||
render :action => "index"
|
||||
@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
|
||||
|
@ -18,12 +61,13 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
|
|||
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,"description"=>location.description}
|
||||
@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
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue