all of user can get json of gprs from outside
This commit is contained in:
		
							parent
							
								
									b4f5a0b04b
								
							
						
					
					
						commit
						11fefa100f
					
				|  | @ -1,29 +1,73 @@ | |||
| class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController | ||||
| 
 | ||||
| 	def index | ||||
| 		@newlocation = Location.new | ||||
| 	end | ||||
|   before_filter :clean_values, :only => [:create, :update] | ||||
| 
 | ||||
| 	def create | ||||
| 		debugger  | ||||
| 		@newlocation = Location.new(params[:location]) | ||||
| 		@newlocation.save! | ||||
| 		render :action => "index" | ||||
| 	end | ||||
|   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 get_locations  | ||||
| 		locations = Location.all | ||||
| 		@data = Array.new | ||||
|   def index | ||||
|     @locations = Location.all | ||||
|     respond_to do |format| | ||||
|       format.html # new.html.erb | ||||
|       format.json { render json: @locations } | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
| 		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} | ||||
| 		end | ||||
| 		render :json => @data.to_json | ||||
| 	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 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue