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

#polymorphic_filter_params

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) batch_create



92
93
94
# File 'app/controllers/georeferences_controller.rb', line 92

def batch_create

end

- (Object) create

POST /georeferences POST /georeferences.json



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

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



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

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



122
123
124
# File 'app/controllers/georeferences_controller.rb', line 122

def download
  send_data Georeference.generate_download(Georeference.where(project_id: sessions_current_project_id)), type: 'text', filename: "georeferences_#{DateTime.now.to_s}.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.



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'app/controllers/georeferences_controller.rb', line 134

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.



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

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?

  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