Class: GeoreferencesController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/georeferences_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods inherited from ApplicationController

#digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #project_matches, #record_not_found, #set_project_from_params

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Method Details

- (Object) batch_create



105
106
# File 'app/controllers/georeferences_controller.rb', line 105

def batch_create
end

- (Object) create

POST /georeferences POST /georeferences.json



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/controllers/georeferences_controller.rb', line 87

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.'
      }
      #         redirect_to url_for(@georeference.metamorphosize),
      #                     notice: "Georeference name '#{@georeference.name}' was successfully created." }
      format.json { render :show, status: :created, location: @georeference.metamorphosize }
    else
      format.html { render action: :new }
      format.json { render json: @georeference.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /georeferences/1 DELETE /georeferences/1.json



125
126
127
128
129
130
131
# File 'app/controllers/georeferences_controller.rb', line 125

def destroy
  @georeference.destroy!
  respond_to do |format|
    format.html { redirect_to georeferences_url }
    format.json { head :no_content }
  end
end

- (Object) download

GET /georeferences/download



134
135
136
137
138
# File 'app/controllers/georeferences_controller.rb', line 134

def download
  send_data(Download.generate_csv(Georeference.where(project_id: sessions_current_project_id)),
            type:     'text',
            filename: "georeferences_#{DateTime.now}.csv")
end

- (Object) edit

GET /georeferences/1/edit



37
38
39
# File 'app/controllers/georeferences_controller.rb', line 37

def edit
  # presents a "Can't edit message at present"
end

- (Object) filter_params (private)



142
143
144
145
146
147
# File 'app/controllers/georeferences_controller.rb', line 142

def filter_params
  params.permit(
    :collecting_event_id,
    collecting_event_ids: [],
  )
end

- (Object) georeference_params (private)



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'app/controllers/georeferences_controller.rb', line 154

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,
    geographic_item_attributes: [:shape],
    origin_citation_attributes: [:id, :_destroy, :source_id, :pages]
  )
end

- (Object) index

GET /georeferences GET /georeferences.json



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/georeferences_controller.rb', line 9

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

- (Object) list



21
22
23
# File 'app/controllers/georeferences_controller.rb', line 21

def list
  @georeferences = Georeference.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10) #.per(3)
end

- (Object) new

GET /georeferences/1 GET /georeferences/1.json



32
33
34
# File 'app/controllers/georeferences_controller.rb', line 32

def new
  redirect_to new_georeferences_geo_locate_path
end

- (Object) set_georeference (private)



149
150
151
152
# File 'app/controllers/georeferences_controller.rb', line 149

def set_georeference
  @georeference = Georeference.with_project_id(sessions_current_project_id).find(params[:id])
  @recent_object = @georeference
end

- (Object) show

GET /georeferences/1 GET /georeferences/1.json



27
28
# File 'app/controllers/georeferences_controller.rb', line 27

def show
end

- (Object) skip

GET /georeferences/skip



42
43
44
45
46
47
48
49
50
# File 'app/controllers/georeferences_controller.rb', line 42

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