Permalink
Browse files

Merge branch 'development'

  • Loading branch information...
mjy committed Dec 14, 2018
2 parents 45cc33b + 704ec48 commit 01dc66694beec8bd16a65809ec6273e658ed1f4f
Showing with 1,706 additions and 833 deletions.
  1. +1 −1 app/assets/javascripts/views/people/_role_picker.js
  2. +27 −5 app/controllers/collecting_events_controller.rb
  3. +4 −4 app/controllers/people_controller.rb
  4. +21 −19 app/controllers/tasks/gis/locality_controller.rb
  5. +33 −56 app/controllers/tasks/gis/match_georeference_controller.rb
  6. +11 −28 app/helpers/documentation_helper.rb
  7. +13 −0 app/helpers/documents_helper.rb
  8. +4 −4 app/helpers/otus_helper.rb
  9. +1 −0 app/javascript/vue/loan/main.js
  10. +5 −7 app/javascript/vue/tasks/uniquify/people/app.vue
  11. +6 −4 app/models/application_record.rb
  12. +9 −119 app/models/collecting_event.rb
  13. +3 −2 app/models/collection_object.rb
  14. +2 −0 app/models/collection_object_observation.rb
  15. +1 −0 app/models/content.rb
  16. +12 −3 app/models/document.rb
  17. +1 −1 app/models/documentation.rb
  18. +3 −3 app/models/geographic_area.rb
  19. +24 −4 app/models/geographic_areas_geographic_item.rb
  20. +16 −9 app/models/geographic_item.rb
  21. +2 −1 app/models/note.rb
  22. +2 −0 app/models/observation.rb
  23. +24 −4 app/models/person.rb
  24. +1 −1 app/models/protonym.rb
  25. +4 −2 app/models/source.rb
  26. +1 −0 app/models/taxon_determination.rb
  27. +12 −5 app/models/taxon_name.rb
  28. +1 −1 app/models/taxon_name_relationship.rb
  29. +1 −2 app/views/collecting_events/index.json.jbuilder
  30. +2 −0 app/views/sources/list.html.erb
  31. +6 −2 app/views/tasks/sources/browse/_result.html.erb
  32. +63 −0 config/initializers/application_record/nilify_blanks.rb
  33. +0 −25 config/initializers/nilify_blanks.rb
  34. +5 −5 db/schema.rb
  35. +0 −37 lib/activerecord_utilities.rb
  36. +208 −0 lib/queries/collecting_event/filter.rb
  37. +2 −2 lib/queries/collection_object_filter_query.rb
  38. +203 −0 lib/queries/concerns/date_ranges.rb
  39. +8 −1 lib/queries/person/autocomplete.rb
  40. +1 −1 lib/queries/tag/filter.rb
  41. +1 −1 lib/tasks/import/3i/3i.rake
  42. +167 −22 lib/tasks/import/sf/sf_citations.rake
  43. +10 −10 lib/tasks/import/sf/sf_import_all.rake
  44. +2 −2 lib/tasks/import/sf/sf_start.rake
  45. +1 −1 lib/tasks/import/sf/sf_taxa.rake
  46. +14 −14 lib/utilities/dates.rb
  47. +1 −2 spec/README.md
  48. +54 −0 spec/config/application_record/nilify_blanks.rb
  49. +1 −7 spec/factories/geographic_area_factory.rb
  50. +4 −3 spec/factories/geographic_item_factory.rb
  51. +0 −52 spec/lib/activerecord_utilities_spec.rb
  52. +129 −0 spec/lib/queries/collecting_event/filter_spec.rb
  53. +2 −7 spec/models/collecting_event/dates_spec.rb
  54. +7 −0 spec/models/collecting_event_spec.rb
  55. +7 −0 spec/models/collection_object_observation_spec.rb
  56. +21 −0 spec/models/collection_object_spec.rb
  57. +9 −0 spec/models/content_spec.rb
  58. +23 −8 spec/models/document_spec.rb
  59. +7 −0 spec/models/note_spec.rb
  60. +7 −0 spec/models/observation_spec.rb
  61. +334 −0 spec/models/person/merge_spec.rb
  62. +103 −336 spec/models/person_spec.rb
  63. +15 −5 spec/models/protonym_specs/soft_validation_spec.rb
  64. +23 −0 spec/models/source_spec.rb
  65. +9 −0 spec/models/taxon_determination_spec.rb
  66. +12 −5 spec/models/taxon_name_specs/cached_spec.rb
@@ -96,7 +96,7 @@ Object.assign(TW.views.people.role_picker, {
}
}).autocomplete("instance")._renderItem = function (ul, item) {
return $("<li class='autocomplete'>")
.append("<a>" + item.label + ' <span class="hoverme" data-person-id="' + item.object_id + '">...</span></a>')
.append("<a>" + item.label_html + ' <span class="hoverme" data-person-id="' + item.object_id + '">...</span></a>')
.appendTo(ul);
};

@@ -4,10 +4,17 @@ class CollectingEventsController < ApplicationController
before_action :set_collecting_event, only: [:show, :edit, :update, :destroy, :card]

# GET /collecting_events
# GET /collecting_events.jso
# GET /collecting_events.json
def index
@recent_objects = CollectingEvent.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
render '/shared/data/all/index'
respond_to do |format|
format.html do
@recent_objects = CollectingEvent.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
render '/shared/data/all/index'
end
format.json {
@collecting_events = Queries::CollectingEvent::Filter.new(filter_params).all.page(params[:page]).per(500)
}
end
end

# GET /collecting_events/1
@@ -166,13 +173,11 @@ def select_options

private

# Use callbacks to share common setup or constraints between actions.
def set_collecting_event
@collecting_event = CollectingEvent.with_project_id(sessions_current_project_id).find(params[:id])
@recent_object = @collecting_event
end

# Never trust parameters from the scary internet, only allow the white list through.
def collecting_event_params
params.require(:collecting_event).permit(
:verbatim_label, :print_label, :print_label_number_to_print, :document_label,
@@ -194,4 +199,21 @@ def collecting_event_params
def batch_params
params.permit(:ce_namespace, :file, :import_level).merge(user_id: sessions_current_user_id, project_id: sessions_current_project_id).to_h.symbolize_keys
end

def filter_params
params.permit(
Queries::CollectingEvent::Filter::ATTRIBUTES,
:in_labels,
:in_verbatim_locality,
:recent,
:shape,
:start_date,
:end_date,
:partial_overlap_dates,
:start_day, :start_month, :start_year,
:end_day, :end_month, :end_year,
keyword_ids: [],
spatial_geographic_area_ids: []
)
end
end
@@ -93,15 +93,15 @@ def search

def autocomplete
@people = Queries::Person::Autocomplete.new(
params.require(:term),
params.permit(:term)[:term],
autocomplete_params
).autocomplete
end

def merge
old_person = Person.find(params[:id])
@person = Person.find(params[:new_person_id])
if old_person.merge_with(@person.id)
@person = Person.find(params[:id]) # the person to *keep*
person_to_remove = Person.find(params[:person_to_destroy])
if @person.hard_merge(person_to_remove.id)
render 'show'
else
render json: {status: 'Failed'}
@@ -27,26 +27,28 @@ def new_list
# use the params[:geographic_area_id] to locate the area, use that to find a geographic item
def list
case params[:commit]
when 'Show'
geographic_area_ids = params[:geographic_area_ids]
shape_in = params['drawn_area_shape']
findings = [params['selection_objects']]
when 'Show'
geographic_area_ids = params[:geographic_area_ids]
shape_in = params['drawn_area_shape']
findings = [params['selection_objects']]

findings.flatten.each { |finding|
case finding
when /Collecting/
@collecting_events = GeographicItem.gather_geographic_area_or_shape_data(geographic_area_ids,
shape_in,
finding,
sessions_current_project_id)
.order(:verbatim_locality)
else
raise("Cannot find '#{finding}' this way.")
end
}
@drawing_modes = 'active: polygon, circle'
else
# some other case, TBDL
findings.flatten.each { |finding|
case finding
when /Collecting/
@collecting_events = GeographicItem.gather_geographic_area_or_shape_data(
geographic_area_ids,
shape_in,
finding,
sessions_current_project_id)
.order(:verbatim_locality)
else
raise("Cannot find '#{finding}' this way.")
end
}
@drawing_modes = 'active: polygon, circle'
else
# some other case, TBDL
end
end

end
@@ -22,8 +22,8 @@ def recent_collecting_events
message = ''
how_many = params['how_many']
@collecting_events = CollectingEvent.with_project_id(sessions_current_project_id)
.order(updated_at: :desc)
.limit(how_many.to_i)
.order(updated_at: :desc)
.limit(how_many.to_i)

if @collecting_events.blank?
message = 'no recent objects selected'
@@ -40,8 +40,8 @@ def tagged_collecting_events
else
keyword = Keyword.find(params[:keyword_id])
@collecting_events = CollectingEvent.with_project_id(sessions_current_project_id)
.order(updated_at: :desc)
.tagged_with_keyword(keyword)
.order(updated_at: :desc)
.tagged_with_keyword(keyword)
end

if @collecting_events.blank?
@@ -51,7 +51,6 @@ def tagged_collecting_events
end

def drawn_collecting_events

message = ''
value = params['ce_geographic_item_attributes_shape']
if value.blank?
@@ -64,15 +63,15 @@ def drawn_collecting_events
geometry = geometry.as_text
radius = feature['radius']
case this_type
when 'point'
@collecting_events = CollectingEvent.with_project_id(sessions_current_project_id)
.joins(:geographic_items)
.where(GeographicItem.within_radius_of_wkt_sql(geometry, radius))
when 'polygon'
@collecting_events = CollectingEvent.with_project_id(sessions_current_project_id)
.joins(:geographic_items)
.where(GeographicItem.contained_by_wkt_sql(geometry))
else
when 'point'
@collecting_events = CollectingEvent.with_project_id(sessions_current_project_id)
.joins(:geographic_items)
.where(GeographicItem.within_radius_of_wkt_sql(geometry, radius))
when 'polygon'
@collecting_events = CollectingEvent.with_project_id(sessions_current_project_id)
.joins(:geographic_items)
.where(GeographicItem.contained_by_wkt_sql(geometry))
else
end
end

@@ -95,8 +94,8 @@ def recent_georeferences
message = ''
how_many = params['how_many']
@georeferences = Georeference.with_project_id(sessions_current_project_id)
.order(updated_at: :desc)
.limit(how_many.to_i)
.order(updated_at: :desc)
.limit(how_many.to_i)
if @georeferences.blank?
message = 'no recent georeferences selected'
end
@@ -113,8 +112,8 @@ def tagged_georeferences
else
keyword = Keyword.find(params[:keyword_id])
@georeferences = Georeference.with_project_id(sessions_current_project_id)
.order(updated_at: :desc)
.tagged_with_keyword(keyword)
.order(updated_at: :desc)
.tagged_with_keyword(keyword)
end
if @georeferences.blank?
message = 'no tagged objects selected'
@@ -133,48 +132,26 @@ def drawn_georeferences
geometry = feature.geometry
this_type = geometry.geometry_type.to_s.downcase
geometry = geometry.as_text

radius = feature['radius']
case this_type
when 'point'
@georeferences = Georeference.with_project_id(sessions_current_project_id)
.joins(:geographic_item)
.where(GeographicItem.within_radius_of_wkt_sql(geometry, radius))
when 'polygon'
@georeferences = Georeference.with_project_id(sessions_current_project_id)
.joins(:geographic_item)
.where(GeographicItem.contained_by_wkt_sql(geometry))
else
when 'point'
@georeferences = Georeference.with_project_id(sessions_current_project_id)
.joins(:geographic_item)
.where(GeographicItem.within_radius_of_wkt_sql(geometry, radius))
when 'polygon'
@georeferences = Georeference.with_project_id(sessions_current_project_id)
.joins(:geographic_item)
.where(GeographicItem.contained_by_wkt_sql(geometry))
else
end
if @georeferences.blank?
message = 'no objects contained in drawn shape'
end
render_gr_select_json(message)
if @georeferences.blank?
message = 'no objects contained in drawn shape'
end
render_gr_select_json(message)
end
end

#
# def anti_meridian_check(last_x, this_x) # returns true if anti-meridian crossed
# if last_x
# if last_x <= 0
# if (((this_x >= 0 || this_x < -180))) # sign change from west to east
# xm = (0.5 * (this_x - last_x)).abs # find intersection
# if (xm > 90)
# return true
# end
# end
# end
# if last_x >= 0
# if (((this_x <= 0) || this_x > 180))
# xm = (0.5 * (last_x - this_x)).abs
# if (xm > 90)
# return true
# end
# end
# end
# end
# false
# end
#
def batch_create_match_georeferences
message = ''
respond_to do |format|
@@ -194,15 +171,15 @@ def batch_create_match_georeferences
arguments[:checked_ids] = checked_ids

results = Georeference.with_project_id(sessions_current_project_id)
.batch_create_from_georeference_matcher(arguments)
.batch_create_from_georeference_matcher(arguments)

if results.blank?
message = 'No collecting events were selected.'
end

html = render_to_string(partial: 'georeference_success', formats: 'html',
locals: {georeferences_results: results}
)
)

render json: {message: message,
html: html
@@ -9,42 +9,25 @@ def documentation_tag(documentation)

def documentation_link(documentation)
return nil if documentation.nil?
link_to(documentation_tag(documentation).html_safe, documentation)
link_to(documentation_tag(documentation), documentation).html_safe
end

def document_viewer_target(object)
viewer_documents(object).first
end

def viewer_documents(object)
document_ids = []

sessions_current_user.pinboard
# pinboard - top document
# pinboard -

# So- behaviour.
# We need to allow the user to choose a document to show.
# That document should be, in order of priority:
# 1) the pinned Doucment that is_inserted = true
# 2) the pinned Document
# 3) the pinned Source that is_inserted (if it has a PDF)
# 4) the pinned Source (if it has a PDF)
# If there is none of 1-4 you get help message saying what to do OR we just don’t display the slide out. I could
# write a boolean returning method to dtermine if any of 1-4 are available.
# Just thought of another thing on way in - If a record has a citation, then the source for that Citation should
# be pre-loaded (assuming source has PDF)


def documentation_download_link(documentation)
return nil if documentation.nil?
link_to(
document_type_label(documentation.document),
documentation.document.document_file.url(),
title: documentation.document.document_file_file_name,
data: {icon: :download} )
end

# @param [Object] object
def document_toggle_tag(object) # TODO: Apparently unused...
content_tag(:div, class: 'document_toggle_tag') do
viewer_documents.each do |document_id|
# content_tag(:span, link_to(content_tag(Document.find(document_id), '/view/pdf/link/or/onclick')))
end
end
def documentation_links(object)
object.documentation.collect{ |o| documentation_download_link(o)}.join("&nbsp;|&nbsp;").html_safe
end


end
@@ -14,4 +14,17 @@ def documents_search_form
render('/documents/quick_search_form')
end

def document_type_label(document)
case document.document_file_content_type
when 'application/pdf'
'pdf'
when 'application/octet-stream'
'binary (Word or other)'
when 'text/plain'
'text'
when 'text/xml'
'xml'
end
end

end
@@ -4,10 +4,10 @@ def otu_tag(otu)
return nil if otu.nil?
a = content_tag(:span, otu.name, class: :otu_tag_otu_name) if otu.name
b = content_tag(:span, full_taxon_name_tag(otu.taxon_name).html_safe, class: :otu_tag_taxon_name) if otu.taxon_name_id
if otu.taxon_name_id && otu.taxon_name.rank_class.to_s =~ /Genus/
b += " sp."
b = b.gsub('"</span> sp.', ' sp."</span>').gsub('</span> sp.', ' sp.</span>')
end
# if otu.taxon_name_id && otu.taxon_name.rank_class.to_s =~ /Genus/
# b += " sp."
# b = b.gsub('"</span> sp.', ' sp."</span>').gsub('</span> sp.', ' sp.</span>')
# end
content_tag(:span, [b,a].compact.join.html_safe, class: :otu_tag)
end

@@ -10,6 +10,7 @@ import { newStore } from './store/store.js'

Object.assign(TW.views.tasks.loan, {
init: function () {
var store = newStore()
Vue.use(vueResource)
Vue.http.headers.common['X-CSRF-Token'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content')

Oops, something went wrong.

0 comments on commit 01dc666

Please sign in to comment.