Class: GeoreferencesController

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

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

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

#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form

Methods included from Api::Intercept

#intercept_api

Instance Method Details

- (Object) batch_create



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

def batch_create
end

- (Object) create

POST /georeferences POST /georeferences.json



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# 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.'
      }
      #         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



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

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



132
133
134
135
136
# File 'app/controllers/georeferences_controller.rb', line 132

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



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

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

- (Object) filter_params (private)



140
141
142
143
144
145
# File 'app/controllers/georeferences_controller.rb', line 140

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

- (Object) georeference_params (private)



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

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



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

- (Object) list



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

- (Object) new

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

- (Object) set_georeference (private)



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

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



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

def show
end

- (Object) skip

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

- (Object) update

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