Class: Georeferences::GeoLocatesController

Inherits:
ApplicationController
  • Object
show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/georeferences/geo_locates_controller.rb

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Instance Method Details

#createObject

POST /georeferences/geo_locates POST /georeferences/geo_locates.json



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/georeferences/geo_locates_controller.rb', line 6

def create
  @georeference = Georeference::GeoLocate.new(georeference_params)
  respond_to do |format|
    if @georeference.save
      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
        render :new, notice: 'Georeference not created, check verbatim values of collecting event'
        #           if @georeference.collecting_event
        #             redirect_to collecting_event_path(@georeference.collecting_event),
        #           else
        #             redirect_to georeferences_path, notice: 'Georeference not created.  Contact administrator with details if you received dthis message.'
        #           end
        #         end
      }

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

#georeference_paramsObject (protected)



51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/georeferences/geo_locates_controller.rb', line 51

def georeference_params
  params.require(:georeference).permit(:iframe_response,
                                       :submit,
                                       :collecting_event_id,
                                       :type,
                                       :is_public,
                                       :api_request,
                                       origin_citation_attributes: [:id, :_destroy, :source_id, :pages]
  )
end

#newObject

GET /georeferences/geo_locate/new



40
41
42
43
44
45
46
47
# File 'app/controllers/georeferences/geo_locates_controller.rb', line 40

def new
  #   @collecting_event = CollectingEvent.find(params.permit(:collecting_event_id)[:collecting_event_id]) if params.permit(:collecting_event_id)[:collecting_event_id]
  attributes           = {}
  attributes           = georeference_params if params[:georeference]
  @georeference        = Georeference::GeoLocate.new(attributes)
  @georeference.source ||= Source.new()

end

#set_data_modelObject (protected)

Over-ride the default model setting for this subclass



63
64
65
# File 'app/controllers/georeferences/geo_locates_controller.rb', line 63

def set_data_model
  @data_model = Georeference::GeoLocate
end