Class: Cats::Core::LocationsController
  
  
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods included from Common
  #create, #show, #update
  
  
  
  
  
  
  
  
  
  
  #authenticate, #current_user, #skip_bullet
  
  
    Instance Method Details
    
      
  
  
    #children  ⇒ Object 
  
  
  
  
    
      
12
13
14
15 
     | 
    
      # File 'app/controllers/cats/core/locations_controller.rb', line 12
def children
  parent = Location.find(params[:id])
  render json: {success: true, data: serialize(parent.children)}
end
     | 
  
 
    
      
  
  
    #create_fdp  ⇒ Object 
  
  
  
  
    
      
34
35
36
37
38
39 
     | 
    
      # File 'app/controllers/cats/core/locations_controller.rb', line 34
def create_fdp
  service = LocationService.new
  p = fdp_params
  fdp = service.create_fdp(p[:code], p[:name], p[:parent_id], p[:description])
  render json: {success: true, data: serialize(fdp)}
end
     | 
  
 
    
      
  
  
    #filter  ⇒ Object 
  
  
  
  
    
      
17
18
19
20 
     | 
    
      # File 'app/controllers/cats/core/locations_controller.rb', line 17
def filter
  query = Location.ransack(params[:q])
  render json: {success: true, data: serialize(query.result)}
end
     | 
  
 
    
      
  
  
    #filter_location_by_region  ⇒ Object 
  
  
  
  
    
      
22
23
24
25
26 
     | 
    
      # File 'app/controllers/cats/core/locations_controller.rb', line 22
def filter_location_by_region
  descendants = Location.find(params[:id]).descendants
  query = descendants.ransack(params[:q])
  render json: {success: true, data: serialize(query.result)}
end
     | 
  
 
    
      
  
  
    #index  ⇒ Object 
  
  
  
  
    
      
6
7
8
9
10 
     | 
    
      # File 'app/controllers/cats/core/locations_controller.rb', line 6
def index
  super do
    Location.where(location_type: params[:location_type])
  end
end
     | 
  
 
    
      
  
  
    #woredas  ⇒ Object 
  
  
  
  
    
      
28
29
30
31
32 
     | 
    
      # File 'app/controllers/cats/core/locations_controller.rb', line 28
def woredas
  region = Location.find(params[:id])
  woredas = Location.where(id: region.descendant_ids, location_type: Location::WOREDA)
  render json: {success: true, data: serialize(woredas)}
end
     |