Class: DwcOccurrencesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DwcOccurrencesController
- Defined in:
- app/controllers/dwc_occurrences_controller.rb
Instance Method Summary collapse
-
#api_index ⇒ Object
GET /api/v1/dwc_occurrences.json.
- #collector_id_metadata ⇒ Object
-
#create ⇒ Object
TODO: remove.
-
#download ⇒ Object
GET /dwc_occurence/download.
-
#index ⇒ Object
.json only.
- #metadata ⇒ Object
- #predicates ⇒ Object
- #set_object ⇒ Object protected
- #status ⇒ Object
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#api_index ⇒ Object
GET /api/v1/dwc_occurrences.json
53 54 55 56 57 58 59 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 53 def api_index @dwc_occurrences = Queries::DwcOccurrence::Filter.new(params.merge!(api: true)) .all .where(project_id: sessions_current_project_id) .page(params[:page]).per(params[:per] || 1) render '/dwc_occurrences/api/v1/index' end |
#collector_id_metadata ⇒ Object
35 36 37 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 35 def render json: helpers. end |
#create ⇒ Object
TODO: remove
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 40 def create respond_to do |format| format.html do @object.set_dwc_occurrence redirect_to browse_collection_objects_task_path(collection_object_id: @object.id) end format.json { render status: :found and return } end end |
#download ⇒ Object
GET /dwc_occurence/download
62 63 64 65 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 62 def download send_data Export::Csv.generate_csv( DwcOccurrence.where(project_id: sessions_current_project_id)), type: 'text', filename: "dwc_occurrence_#{DateTime.now}.tsv" end |
#index ⇒ Object
.json only
9 10 11 12 13 14 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 9 def index @dwc_occurrences = Queries::DwcOccurrence::Filter.new(params).all .where(project_id: sessions_current_project_id) .page(params[:page]) .per(params[:per] || 1) end |
#metadata ⇒ Object
16 17 18 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 16 def @dwc_occurrences = DwcOccurrence.where(project_id: sessions_current_project_id) end |
#predicates ⇒ Object
20 21 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 20 def predicates end |
#set_object ⇒ Object (protected)
69 70 71 72 73 74 75 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 69 def set_object @object = GlobalID::Locator.locate(params[:object_global_id]) if @object.nil? || (@object.project_id != sessions_current_project_id) render status: :not_found and return end end |
#status ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 23 def status if @object render json: { object: params[:object_global_id], id: @object.dwc_occurrence&.id, updated_at: @object.dwc_occurrence&.updated_at } else render json: {}, status: :unprocessable_entity end end |