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

rubocop:enable Metrics/MethodLength, Metrics/BlockNesting



94
95
96
# File 'app/controllers/georeferences_controller.rb', line 94

def batch_create

end

- (Object) create

rubocop:disable Metrics/MethodLength, Metrics/BlockNesting POST /georeferences POST /georeferences.json



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'app/controllers/georeferences_controller.rb', line 48

def create
  @georeference = Georeference.new(georeference_params)
  if params['skip_next'].nil?
    respond_to do |format|
      if @georeference.save

      # target = @georeference.collecting_event

      # unless params['commit_next'].nil?
      #   new_target = @georeference.collecting_event.next_without_georeference
      #   target     = new_target unless new_target.nil?
      # end

        format.html {
          if false

          else
            redirect_to collecting_event_path(@georeference.collecting_event), notice: 'Georeference was successfully created.'
          end
        }

        format.json { render action: 'show', status: :created }

      else

        format.html {
          if @georeference.method_name
            render "/georeferences/#{@georeference.method_name}/new"
          else
            if @georeference.collecting_event
              redirect_to collecting_event_path(@georeference.collecting_event), notice: 'Georeference not created, check verbatim values of collecting event'
            else
              redirect_to georeferences_path, notice: 'Georeference not created.  Contact administrator with details if you recieved this message.'
            end
          end
        }

        format.json { render json: @georeference.errors, status: :unprocessable_entity }
      end
    end
  else
    skip
  end
end

- (Object) destroy

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



115
116
117
118
119
120
121
# File 'app/controllers/georeferences_controller.rb', line 115

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



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

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



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

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

- (Object) georeference_params (private)

Never trust parameters from the scary internet, only allow the white list through.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'app/controllers/georeferences_controller.rb', line 138

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
# File 'app/controllers/georeferences_controller.rb', line 9

def index
  @recent_objects = Georeference.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

- (Object) list



14
15
16
# File 'app/controllers/georeferences_controller.rb', line 14

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



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

def new
  redirect_to new_georeferences_geo_locate_path
end

- (Object) set_georeference (private)

Use callbacks to share common setup or constraints between actions.



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

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



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

def show
end

- (Object) skip

GET /georeferences/skip



35
36
37
38
39
40
41
42
43
# File 'app/controllers/georeferences_controller.rb', line 35

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