Class: GeoreferencesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- GeoreferencesController
- Defined in:
- app/controllers/georeferences_controller.rb
Instance Method Summary collapse
- #batch_create ⇒ Object
-
#create ⇒ Object
POST /georeferences POST /georeferences.json.
-
#destroy ⇒ Object
DELETE /georeferences/1 DELETE /georeferences/1.json.
-
#download ⇒ Object
GET /georeferences/download.
-
#edit ⇒ Object
GET /georeferences/1/edit.
- #filter_params ⇒ Object private
- #georeference_params ⇒ Object private
-
#index ⇒ Object
GET /georeferences GET /georeferences.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /georeferences/1 GET /georeferences/1.json.
- #set_georeference ⇒ Object private
-
#show ⇒ Object
GET /georeferences/1 GET /georeferences/1.json.
-
#skip ⇒ Object
GET /georeferences/skip.
-
#update ⇒ Object
PATCH/PUT /georeferences/1 PATCH/PUT /georeferences/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
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
#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form
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
#batch_create ⇒ Object
101 102 |
# File 'app/controllers/georeferences_controller.rb', line 101 def batch_create end |
#create ⇒ Object
POST /georeferences POST /georeferences.json
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/controllers/georeferences_controller.rb', line 86 def create @georeference = Georeference.new(georeference_params) respond_to do |format| if @georeference.save format.html { redirect_to collecting_event_path(@georeference.collecting_event), notice: 'Georeference was successfully created.' } format.json { render :show, status: :created, location: @georeference. } else format.html { render action: :new } format.json { render json: @georeference.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /georeferences/1 DELETE /georeferences/1.json
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'app/controllers/georeferences_controller.rb', line 120 def destroy @georeference.destroy respond_to do |format| if @georeference.destroyed? format.html { destroy_redirect @georeference, notice: 'Georeference was successfully destroyed.' } format.json { head :no_content} else format.html { destroy_redirect @georeference, notice: 'Georeference was not destroyed, ' + @georeference.errors..join('; ') } format.json { render json: @georeference.errors, status: :unprocessable_entity } end end end |
#download ⇒ Object
GET /georeferences/download
134 135 136 137 138 139 |
# File 'app/controllers/georeferences_controller.rb', line 134 def download send_data( Export::Download.generate_csv(Georeference.where(project_id: sessions_current_project_id)), type: 'text', filename: "georeferences_#{DateTime.now}.csv") end |
#edit ⇒ Object
GET /georeferences/1/edit
36 37 38 |
# File 'app/controllers/georeferences_controller.rb', line 36 def edit # presents a "Can't edit message at present" end |
#filter_params ⇒ Object (private)
143 144 145 146 147 148 |
# File 'app/controllers/georeferences_controller.rb', line 143 def filter_params params.permit( :collecting_event_id, collecting_event_ids: [], ) end |
#georeference_params ⇒ Object (private)
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'app/controllers/georeferences_controller.rb', line 155 def georeference_params params.require(:georeference).permit( :iframe_response, :submit, :geographic_item_id, :collecting_event_id, :error_radius, :error_depth, :error_geographic_item_id, :type, :position, :is_public, :api_request, :is_undefined_z, :is_median_z, :year_georeferenced, :day_georeferenced, :month_georeferenced, :wkt, geographic_item_attributes: [:shape], origin_citation_attributes: [:id, :_destroy, :source_id, :pages] ) end |
#index ⇒ Object
GET /georeferences GET /georeferences.json
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/georeferences_controller.rb', line 8 def index respond_to do |format| format.html do @recent_objects = Georeference.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @georeferences = Queries::Georeference::Filter.new(filter_params).all.where(project_id: sessions_current_project_id).page(params[:page]).per(50) } end end |
#list ⇒ Object
20 21 22 |
# File 'app/controllers/georeferences_controller.rb', line 20 def list @georeferences = Georeference.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10) #.per(3) end |
#new ⇒ Object
GET /georeferences/1 GET /georeferences/1.json
31 32 33 |
# File 'app/controllers/georeferences_controller.rb', line 31 def new redirect_to new_georeferences_geo_locate_path end |
#set_georeference ⇒ Object (private)
150 151 152 153 |
# File 'app/controllers/georeferences_controller.rb', line 150 def set_georeference @georeference = Georeference.with_project_id(sessions_current_project_id).find(params[:id]) @recent_object = @georeference end |
#show ⇒ Object
GET /georeferences/1 GET /georeferences/1.json
26 27 |
# File 'app/controllers/georeferences_controller.rb', line 26 def show end |
#skip ⇒ Object
GET /georeferences/skip
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/georeferences_controller.rb', line 41 def skip target = @georeference.collecting_event.next_without_georeference target = @georeference.collecting_event if target.nil? # TODO: check on subsequent use of 'target' respond_to do |format| format.html { redirect_to target, notice: 'All collecting events have georeferences.' } format.json { render action: 'show', status: :created, location: target } end end |
#update ⇒ Object
PATCH/PUT /georeferences/1 PATCH/PUT /georeferences/1.json
106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/controllers/georeferences_controller.rb', line 106 def update respond_to do |format| if @georeference.update(georeference_params) format.html { redirect_to @georeference., notice: 'Georeference was successfully updated.' } format.json { render :show, status: :ok, location: @georeference. } else format.html { render action: :edit} # "/georeferences/#{@georeference.method_name}/edit"} format.json { render json: @georeference.errors, status: :unprocessable_entity } end end end |