Class: GeographicAreasController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- GeographicAreasController
- Defined in:
- app/controllers/geographic_areas_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #autocomplete ⇒ Object
-
#by_lat_long ⇒ Object
!! Almost certain @mjy did similar somewhere else too !! GET /geographic_areas/by_lat_long.json?latitude=0.0&longitude=10.1.
- #display_coordinates ⇒ Object
-
#download ⇒ Object
GET /geographic_areas/download.
- #geographic_area_params ⇒ Object private
-
#index ⇒ Object
GET /geographic_areas GET /geographic_areas.json.
- #list ⇒ Object
- #search ⇒ Object
-
#select_options ⇒ Object
GET /geographic_areas/select_options.json.
- #set_geographic_area ⇒ Object private
-
#show ⇒ Object
GET /geographic_areas/1 GET /geographic_areas/1.json.
Methods included from DataControllerConfiguration::SharedDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#autocomplete ⇒ Object
48 49 50 51 |
# File 'app/controllers/geographic_areas_controller.rb', line 48 def autocomplete c = Queries::GeographicArea::Autocomplete.new(params[:term], project_id: [sessions_current_project_id]).autocomplete @geographic_areas = c #.sort_by{|geographic_area| -(geographic_area.has_shape? && 1||0) } end |
#by_lat_long ⇒ Object
!! Almost certain @mjy did similar somewhere else too !! GET /geographic_areas/by_lat_long.json?latitude=0.0&longitude=10.1
65 66 67 68 69 70 71 |
# File 'app/controllers/geographic_areas_controller.rb', line 65 def by_lat_long @geographic_areas = GeographicArea.find_smallest_by_lat_long( params.require(:latitude).to_f, params.require(:longitude).to_f ) render action: :autocomplete end |
#display_coordinates ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/geographic_areas_controller.rb', line 30 def display_coordinates @asserted_distribution = AssertedDistribution.new @json_coors = params.to_json render partial: '/asserted_distributions/quick_form' end |
#download ⇒ Object
GET /geographic_areas/download
54 55 56 |
# File 'app/controllers/geographic_areas_controller.rb', line 54 def download send_data Export::CSV.generate_csv(GeographicArea.all), type: 'text', filename: "geographic_areas_#{DateTime.now}.tsv" end |
#geographic_area_params ⇒ Object (private)
80 81 82 83 84 85 |
# File 'app/controllers/geographic_areas_controller.rb', line 80 def geographic_area_params params.require(:geographic_area).permit( :name, :level0_id, :level1_id, :level2_id, :parent_id, :geographic_area_type_id, :iso_3166_a2, :iso_3166_a3, :tdwgID, :data_origin) end |
#index ⇒ Object
GET /geographic_areas GET /geographic_areas.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/geographic_areas_controller.rb', line 9 def index respond_to do |format| format.html do @recent_objects = GeographicArea.updated_in_last(2.months).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @geographic_areas = ::Queries::GeographicArea::Filter.new(params).all .includes(:geographic_items) .page(params[:page]) .per(params[:per]) # .order('geographic_items.cached_total_area, geographic_area.name') } end end |
#list ⇒ Object
36 37 38 |
# File 'app/controllers/geographic_areas_controller.rb', line 36 def list @geographic_areas = GeographicArea.order(:id).page(params[:page]) end |
#search ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/controllers/geographic_areas_controller.rb', line 40 def search if params[:id].blank? redirect_to geographic_areas_path, alert: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to geographic_area_path(params[:id]) end end |
#select_options ⇒ Object
GET /geographic_areas/select_options.json
59 60 61 |
# File 'app/controllers/geographic_areas_controller.rb', line 59 def @geographic_areas = GeographicArea.select_optimized(sessions_current_user_id, sessions_current_project_id, params.permit(:target)[:target]) end |
#set_geographic_area ⇒ Object (private)
75 76 77 78 |
# File 'app/controllers/geographic_areas_controller.rb', line 75 def set_geographic_area @geographic_area = GeographicArea.find(params[:id]) @recent_object = @geographic_area end |
#show ⇒ Object
GET /geographic_areas/1 GET /geographic_areas/1.json
27 28 |
# File 'app/controllers/geographic_areas_controller.rb', line 27 def show end |