Class: GeoreferencesController

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

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RedirectHelper

#destroy_redirect

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

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

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#batch_createObject



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

def batch_create
end

#createObject

POST /georeferences POST /georeferences.json



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

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.metamorphosize }
    else
      format.html { render action: :new }
      format.json { render json: @georeference.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

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



123
124
125
126
127
128
129
130
131
132
133
134
# File 'app/controllers/georeferences_controller.rb', line 123

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.full_messages.join('; ') }
      format.json { render json: @georeference.errors, status: :unprocessable_entity }
    end
  end
end

#downloadObject

GET /georeferences/download



137
138
139
140
141
142
# File 'app/controllers/georeferences_controller.rb', line 137

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

#editObject

GET /georeferences/1/edit



39
40
41
# File 'app/controllers/georeferences_controller.rb', line 39

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

#georeference_paramsObject (private)



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

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

#indexObject

GET /georeferences GET /georeferences.json



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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(params).all
      .where(project_id: sessions_current_project_id)
      .page(params[:page])
      .per(params[:per])
    }
  end
end

#listObject



23
24
25
# File 'app/controllers/georeferences_controller.rb', line 23

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

#newObject

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



34
35
36
# File 'app/controllers/georeferences_controller.rb', line 34

def new
  redirect_to new_georeferences_geo_locate_path
end

#set_georeferenceObject (private)



146
147
148
149
# File 'app/controllers/georeferences_controller.rb', line 146

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

#showObject

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



29
30
# File 'app/controllers/georeferences_controller.rb', line 29

def show
end

#skipObject

GET /georeferences/skip



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

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

#updateObject

PATCH/PUT /georeferences/1 PATCH/PUT /georeferences/1.json



109
110
111
112
113
114
115
116
117
118
119
# File 'app/controllers/georeferences_controller.rb', line 109

def update
  respond_to do |format|
    if @georeference.update(georeference_params)
      format.html { redirect_to @georeference.metamorphosize, notice: 'Georeference was successfully updated.' }
      format.json { render :show, status: :ok, location: @georeference.metamorphosize }
    else
      format.html { render action: :edit} #  "/georeferences/#{@georeference.method_name}/edit"}
      format.json { render json: @georeference.errors, status: :unprocessable_entity }
    end
  end
end