diff --git a/Gemfile.lock b/Gemfile.lock index 70819188..99925450 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -473,6 +473,7 @@ GEM webrick (~> 1.7.0) PLATFORMS + ruby x86_64-linux DEPENDENCIES diff --git a/app/assets/javascripts/datatable_initialisation.js b/app/assets/javascripts/datatable_initialisation.js index 2f94adef..5c8032e5 100644 --- a/app/assets/javascripts/datatable_initialisation.js +++ b/app/assets/javascripts/datatable_initialisation.js @@ -32,11 +32,11 @@ jQuery(function() { "order": [ 2, 'desc' ] } ); - //HERBARIA - $('#herbaria').DataTable( { + //COLLECTIONS + $('#collections').DataTable( { bProcessing: true, bServerSide: true, - sAjaxSource: $('#herbaria').data('source'), + sAjaxSource: $('#collections').data('source'), "columnDefs": [ { "orderable": false, "targets": 3 } ], diff --git a/app/assets/javascripts/selects_with_select2.js b/app/assets/javascripts/selects_with_select2.js index 765dc5ae..652149a4 100644 --- a/app/assets/javascripts/selects_with_select2.js +++ b/app/assets/javascripts/selects_with_select2.js @@ -46,13 +46,13 @@ jQuery(function() { // INDIVIDUALS $('#individual_taxon_id').select2((select2AutocompleteOptions("/taxa/filter", "a taxon"))); - $('#individual_herbarium_id').select2(select2SingleSelectOptions('an herbarium')); + $('#individual_collection_id').select2(select2SingleSelectOptions('a collection')); $('#individual_tissue_id').select2(select2SingleSelectOptions('a tissue type')); $('#individual_project_ids').select2(select2MultiselectOptions); // INDIVIDUAL SEARCHES $('#individual_search_specimen_id').select2((select2AutocompleteOptions("/individuals/filter?name_only=1", "a specimen"))); - $('#individual_search_herbarium').select2(select2SingleSelectOptions('an herbarium')); + $('#individual_search_collection').select2(select2SingleSelectOptions('a collection')); $('#individual_search_taxon').select2((select2AutocompleteOptions("/taxa/filter?name_only=1", "a taxon"))); // ISOLATES diff --git a/app/controllers/herbaria_controller.rb b/app/controllers/collections_controller.rb similarity index 53% rename from app/controllers/herbaria_controller.rb rename to app/controllers/collections_controller.rb index a008f67c..09d92dc3 100644 --- a/app/controllers/herbaria_controller.rb +++ b/app/controllers/collections_controller.rb @@ -20,80 +20,80 @@ # along with BarKeeper. If not, see . # -class HerbariaController < ApplicationController +class CollectionsController < ApplicationController load_and_authorize_resource - before_action :set_herbarium, only: [:show, :edit, :update, :destroy] + before_action :set_collection, only: [:show, :edit, :update, :destroy] - # GET /herbaria - # GET /herbaria.json + # GET /collections + # GET /collections.json def index respond_to do |format| format.html - format.json { render json: HerbariumDatatable.new(view_context) } + format.json { render json: CollectionDatatable.new(view_context) } end end - # GET /herbaria/1 - # GET /herbaria/1.json + # GET /collections/1 + # GET /collections/1.json def show;end - # GET /herbaria/new + # GET /collections/new def new - @herbarium = Herbarium.new + @collection = Collection.new end - # GET /herbaria/1/edit + # GET /collections/1/edit def edit;end - # POST /herbaria - # POST /herbaria.json + # POST /collections + # POST /collections.json def create - @herbarium = Herbarium.new(herbarium_params) + @collection = Collection.new(collection_params) respond_to do |format| - if @herbarium.save - format.html { redirect_to @herbarium, notice: 'Herbarium was successfully created.' } - format.json { render :show, status: :created, location: @herbarium } + if @collection.save + format.html { redirect_to @collection, notice: 'Collection was successfully created.' } + format.json { render :show, status: :created, location: @collection } else format.html { render :new } - format.json { render json: @herbarium.errors, status: :unprocessable_entity } + format.json { render json: @collection.errors, status: :unprocessable_entity } end end end - # PATCH/PUT /herbaria/1 - # PATCH/PUT /herbaria/1.json + # PATCH/PUT /collections/1 + # PATCH/PUT /collections/1.json def update respond_to do |format| - if @herbarium.update(herbarium_params) - format.html { redirect_to @herbarium, notice: 'Herbarium was successfully updated.' } - format.json { render :show, status: :ok, location: @herbarium } + if @collection.update(collection_params) + format.html { redirect_to @collection, notice: 'Collection was successfully updated.' } + format.json { render :show, status: :ok, location: @collection } else format.html { render :edit } - format.json { render json: @herbarium.errors, status: :unprocessable_entity } + format.json { render json: @collection.errors, status: :unprocessable_entity } end end end - # DELETE /herbaria/1 - # DELETE /herbaria/1.json + # DELETE /collections/1 + # DELETE /collections/1.json def destroy - @herbarium.destroy + @collection.destroy respond_to do |format| - format.html { redirect_to herbaria_url, notice: 'Herbarium was successfully destroyed.' } + format.html { redirect_to collections_url, notice: 'Collection was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. - def set_herbarium - @herbarium = Herbarium.find(params[:id]) + def set_collection + @collection = Collection.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. - def herbarium_params - params.require(:herbarium).permit(:name, :acronym) + def collection_params + params.require(:collection).permit(:name, :acronym) end end diff --git a/app/controllers/individual_searches_controller.rb b/app/controllers/individual_searches_controller.rb index 660753ec..55e2f5dd 100644 --- a/app/controllers/individual_searches_controller.rb +++ b/app/controllers/individual_searches_controller.rb @@ -102,6 +102,6 @@ def set_individual_search # Never trust parameters from the scary internet, only allow the white list through. def individual_search_params params.require(:individual_search).permit(:title, :DNA_bank_id, :has_issue, :has_problematic_location, - :has_taxon, :taxon, :specimen_id, :herbarium) + :has_taxon, :taxon, :specimen_id, :collection) end end diff --git a/app/controllers/individuals_controller.rb b/app/controllers/individuals_controller.rb index e0f9c8bd..e69cf5d2 100644 --- a/app/controllers/individuals_controller.rb +++ b/app/controllers/individuals_controller.rb @@ -131,7 +131,7 @@ def set_individual # Never trust parameters from the scary internet, only allow the white list through. def individual_params params.require(:individual).permit(:specimen_id, :DNA_bank_id, :collector, :specimen_id, :herbarium_code, - :herbarium_id, :country, :state_province, :locality, :latitude, :longitude, + :collection_id, :country, :state_province, :locality, :latitude, :longitude, :latitude_original, :longitude_original, :elevation, :exposition, :habitat, :substrate, :life_form, :collectors_field_number, :collected, :determination, :revision, :confirmation, :comments, :taxon_id, :taxon_name, :tissue_id, diff --git a/app/datatables/herbarium_datatable.rb b/app/datatables/collection_datatable.rb similarity index 65% rename from app/datatables/herbarium_datatable.rb rename to app/datatables/collection_datatable.rb index 37baa64c..d8b881cc 100644 --- a/app/datatables/herbarium_datatable.rb +++ b/app/datatables/collection_datatable.rb @@ -22,7 +22,7 @@ # frozen_string_literal: true -class HerbariumDatatable +class CollectionDatatable include Rails.application.routes.url_helpers delegate :url_helpers, to: 'Rails.application.routes' @@ -35,8 +35,8 @@ def initialize(view) def as_json(_options = {}) { sEcho: params[:sEcho].to_i, - iTotalRecords: Herbarium.count, - iTotalDisplayRecords: herbaria.total_entries, + iTotalRecords: Collection.count, + iTotalDisplayRecords: collections.total_entries, aaData: data } end @@ -44,34 +44,34 @@ def as_json(_options = {}) private def data - herbaria.map do |herbarium| + collections.map do |collection| name = '' - name = link_to herbarium.name, edit_herbarium_path(herbarium) if herbarium.name + name = link_to collection.name, edit_collection_path(collection) if collection.name [ name, - herbarium.acronym, - herbarium.updated_at.in_time_zone('CET').strftime('%Y-%m-%d %H:%M:%S'), - link_to('Delete', herbarium, method: :delete, data: { confirm: 'Are you sure?' }) + collection.acronym, + collection.updated_at.in_time_zone('CET').strftime('%Y-%m-%d %H:%M:%S'), + link_to('Delete', collection, method: :delete, data: { confirm: 'Are you sure?' }) ] end end - def herbaria - @herbaria ||= fetch_herbaria + def collections + @collections ||= fetch_collections end - def fetch_herbaria - herbaria = Herbarium.all.order("#{sort_column} #{sort_direction}") + def fetch_collections + collections = Collection.all.order("#{sort_column} #{sort_direction}") - herbaria = herbaria.page(page).per_page(per_page) + collections = collections.page(page).per_page(per_page) if params[:sSearch].present? - herbaria = herbaria.where('herbaria.name ILIKE :search OR herbaria.acronym ILIKE :search', search: "%#{params[:sSearch]}%") + collections = collections.where('collections.name ILIKE :search OR collections.acronym ILIKE :search', search: "%#{params[:sSearch]}%") end - herbaria + collections end def page @@ -83,7 +83,7 @@ def per_page end def sort_column - columns = %w[herbaria.name herbaria.acronym herbaria.updated_at] + columns = %w[collections.name collections.acronym collections.updated_at] columns[params[:iSortCol_0].to_i] end diff --git a/app/datatables/individual_datatable.rb b/app/datatables/individual_datatable.rb index b93f8d90..53b575c3 100644 --- a/app/datatables/individual_datatable.rb +++ b/app/datatables/individual_datatable.rb @@ -52,12 +52,12 @@ def data taxon = '' taxon = link_to individual.taxon.scientific_name, edit_taxon_path(individual.taxon) if individual.taxon - herbarium = link_to individual.herbarium.acronym, edit_herbarium_path(individual.herbarium) if individual.herbarium + collection = link_to individual.collection.acronym, edit_collection_path(individual.collection) if individual.collection [ link_to(individual.specimen_id, edit_individual_path(individual)), taxon, - herbarium, + collection, individual.collector, individual.collectors_field_number, individual.updated_at.in_time_zone('CET').strftime('%Y-%m-%d %H:%M:%S'), @@ -72,9 +72,9 @@ def individuals def fetch_individuals if @taxon_id - individuals = Individual.includes(:taxon, :herbarium).where(taxon_id: @taxon_id).in_project(@current_default_project).order("#{sort_column} #{sort_direction}") + individuals = Individual.includes(:taxon, :collection).where(taxon_id: @taxon_id).in_project(@current_default_project).order("#{sort_column} #{sort_direction}") else - individuals = Individual.includes(:taxon, :herbarium).in_project(@current_default_project).order("#{sort_column} #{sort_direction}") + individuals = Individual.includes(:taxon, :collection).in_project(@current_default_project).order("#{sort_column} #{sort_direction}") end individuals = individuals.page(page).per_page(per_page) @@ -82,7 +82,7 @@ def fetch_individuals if params[:sSearch].present? individuals = individuals.where('individuals.specimen_id ILIKE :search OR taxa.scientific_name ILIKE :search -OR herbaria.acronym ILIKE :search +OR collections.acronym ILIKE :search OR individuals.collector ILIKE :search OR individuals.collectors_field_number ILIKE :search', search: "%#{params[:sSearch]}%") .references(:taxon) @@ -100,7 +100,7 @@ def per_page end def sort_column - columns = %w[individuals.specimen_id taxa.scientific_name herbaria.acronym individuals.collector individuals.collectors_field_number individuals.updated_at] + columns = %w[individuals.specimen_id taxa.scientific_name collections.acronym individuals.collector individuals.collectors_field_number individuals.updated_at] columns[params[:iSortCol_0].to_i] end diff --git a/app/datatables/individual_search_result_datatable.rb b/app/datatables/individual_search_result_datatable.rb index 2e85fb64..c64f15a3 100644 --- a/app/datatables/individual_search_result_datatable.rb +++ b/app/datatables/individual_search_result_datatable.rb @@ -54,12 +54,12 @@ def data taxon_id = individual.taxon.id end - herbarium = link_to individual.herbarium.acronym, edit_herbarium_path(individual.herbarium) if individual.herbarium + collection = link_to individual.collection.acronym, edit_collection_path(individual.collection) if individual.collection [ link_to(individual.specimen_id, edit_individual_path(individual)), link_to(taxon_name, edit_taxon_path(taxon_id)), - herbarium, + collection, individual.latitude_original, individual.longitude_original, individual.updated_at.in_time_zone('CET').strftime('%Y-%m-%d %H:%M:%S'), @@ -69,14 +69,14 @@ def data end def individuals_data - @search_result ||= IndividualSearch.find_by_id(@search_id).individuals.includes(:taxon, :herbarium).reorder("#{sort_column} #{sort_direction}") + @search_result ||= IndividualSearch.find_by_id(@search_id).individuals.includes(:taxon, :collection).reorder("#{sort_column} #{sort_direction}") @search_result = @search_result.page(page).per_page(per_page) if params[:sSearch].present? @search_result = @search_result.where('individuals.specimen_id ILIKE :search OR taxa.scientific_name ILIKE :search -OR herbaria.acronym ILIKE :search', search: "%#{params[:sSearch]}%") +OR collections.acronym ILIKE :search', search: "%#{params[:sSearch]}%") .references(:taxon) end @@ -92,7 +92,7 @@ def per_page end def sort_column - columns = %w[individuals.specimen_id taxa.scientific_name herbaria.acronym individuals.latitude_original individuals.longitude_original individuals.updated_at] + columns = %w[individuals.specimen_id taxa.scientific_name collections.acronym individuals.latitude_original individuals.longitude_original individuals.updated_at] columns[params[:iSortCol_0].to_i] end diff --git a/app/models/ability.rb b/app/models/ability.rb index 8cd29a12..cc350b71 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -36,7 +36,7 @@ def initialize(user) can %i[edit index filter taxonomy_tree associated_specimen find_ancestry show_individuals show_children], Taxon can %i[edit index filter locality], Individual - can %i[edit index], Herbarium + can %i[edit index], Collection can %i[edit index filter change_via_script as_fasq], Contig can %i[edit index filter show_clusters], Isolate diff --git a/app/models/herbarium.rb b/app/models/collection.rb similarity index 96% rename from app/models/herbarium.rb rename to app/models/collection.rb index 04805605..9aef462b 100644 --- a/app/models/herbarium.rb +++ b/app/models/collection.rb @@ -20,7 +20,7 @@ # along with BarKeeper. If not, see . # -class Herbarium < ApplicationRecord +class Collection < ApplicationRecord include PgSearch::Model validates_presence_of :acronym diff --git a/app/models/concerns/import.rb b/app/models/concerns/import.rb index 7cf846b0..f10df4f1 100644 --- a/app/models/concerns/import.rb +++ b/app/models/concerns/import.rb @@ -66,7 +66,7 @@ def query_dna_bank(id, data_source = 'dna_bank') results[:genus] = unit.at_xpath('//abcd21:GenusOrMonomial')&.content&.strip results[:species_epithet] = unit.at_xpath('//abcd21:FirstEpithet')&.content&.strip results[:infraspecific] = unit.at_xpath('//abcd21:InfraspecificEpithet')&.content&.strip - results[:herbarium] = unit.at_xpath('//abcd21:SourceInstitutionCode')&.content&.strip + results[:collection] = unit.at_xpath('//abcd21:SourceInstitutionCode')&.content&.strip results[:collector] = unit.at_xpath('//abcd21:GatheringAgent')&.content&.strip results[:locality] = unit.at_xpath('//abcd21:LocalityText')&.content&.strip results[:longitude] = unit.at_xpath('//abcd21:LongitudeDecimal')&.content&.strip diff --git a/app/models/individual.rb b/app/models/individual.rb index a631dfda..d2ac27af 100644 --- a/app/models/individual.rb +++ b/app/models/individual.rb @@ -29,7 +29,7 @@ class Individual < ApplicationRecord has_many :isolates belongs_to :taxon - belongs_to :herbarium + belongs_to :collection belongs_to :tissue has_many_attached :voucher_images @@ -53,7 +53,7 @@ class Individual < ApplicationRecord scope :bad_location, -> { bad_latitude.or(Individual.bad_longitude) } def self.to_csv(project_id) - header = %w{ Database_ID specimen_id taxon_name determination herbarium collectors_field_number collector collection_date + header = %w{ Database_ID specimen_id taxon_name determination collection collectors_field_number collector collection_date state_province country latitude longitude elevation exposition locality habitat comments } attributes = %w{ id specimen_id taxon_name determination herbarium_code collectors_field_number collector collected @@ -111,9 +111,9 @@ def read_abcd_results(abcd_results) self.latitude_original = abcd_results[:latitude] if abcd_results[:latitude] self.longitude_original = abcd_results[:longitude] if abcd_results[:longitude] - if abcd_results[:herbarium] - herbarium = Herbarium.find_or_create_by(acronym: abcd_results[:herbarium]) - self.herbarium = herbarium + if abcd_results[:collection] + collection = Collection.find_or_create_by(acronym: abcd_results[:collection]) + self.collection = collection end if abcd_results[:higher_taxon_name] && abcd_results[:higher_taxon_rank] diff --git a/app/models/individual_search.rb b/app/models/individual_search.rb index 3bb7c0ac..829aebb8 100644 --- a/app/models/individual_search.rb +++ b/app/models/individual_search.rb @@ -38,7 +38,7 @@ def individuals end def to_csv - header = %w{ Database_ID specimen_id taxon_name determination herbarium collectors_field_number collector collection_date + header = %w{ Database_ID specimen_id taxon_name determination collection collectors_field_number collector collection_date state_province country latitude longitude elevation exposition locality habitat comments } attributes = %w{ id specimen_id taxon_name determination herbarium_code collectors_field_number collector collected @@ -77,7 +77,7 @@ def find_individuals individuals = individuals.without_taxon if has_taxon == 'no_taxon' end - individuals = individuals.joins(:herbarium).where('herbaria.acronym ilike ?', "%#{herbarium}%") if herbarium.present? + individuals = individuals.joins(:collection).where('collections.acronym ilike ?', "%#{collection}%") if collection.present? individuals = individuals.joins(:taxon).where('taxa.scientific_name ilike ?', "%#{taxon}%") if taxon.present? diff --git a/app/models/isolate.rb b/app/models/isolate.rb index f426a959..82780f19 100644 --- a/app/models/isolate.rb +++ b/app/models/isolate.rb @@ -67,7 +67,7 @@ def self.import(file_path, project_id) isolate.dna_bank_id = row['DNA Bank No.'] if row['DNA Bank No.'] - isolate.tissue_id = 2 # Seems to be always "Leaf (Herbarium)", so no import needed + isolate.tissue_id = 2 # Seems to be always "Leaf (Collection)", so no import needed isolate.negative_control = true if row['Tissue Type'] == 'control' @@ -82,7 +82,7 @@ def self.import(file_path, project_id) individual = Individual.find_or_create_by(specimen_id: individual) # Assign to existing or new individual individual.collector = row['Collector'] - individual.herbarium = row['Herbarium'] + individual.collection = row['Collection'] individual.country = row['Country'] individual.state_province = row['State/Province'] individual.locality = row['Locality'] diff --git a/app/views/herbaria/_form.html.erb b/app/views/collections/_form.html.erb similarity index 72% rename from app/views/herbaria/_form.html.erb rename to app/views/collections/_form.html.erb index b25e12a5..191c5bc8 100644 --- a/app/views/herbaria/_form.html.erb +++ b/app/views/collections/_form.html.erb @@ -1,13 +1,13 @@ -<% provide(:name, @herbarium.name) %> -<%= show_val_errors(@herbarium)%> +<% provide(:name, @collection.name) %> +<%= show_val_errors(@collection)%>
-

<%= @herbarium.name%>

+

<%= @collection.name%>

- <%= form_for(@herbarium) do |f| %> + <%= form_for(@collection) do |f| %>
<%= f.label :name %> <%= f.text_field :name, class: 'form-control' %> diff --git a/app/views/herbaria/edit.html.erb b/app/views/collections/edit.html.erb similarity index 62% rename from app/views/herbaria/edit.html.erb rename to app/views/collections/edit.html.erb index fdd752cc..c34d93e8 100644 --- a/app/views/herbaria/edit.html.erb +++ b/app/views/collections/edit.html.erb @@ -5,7 +5,7 @@ <%= link_to '', 'javascript:history.go(-1)', :class => "glyphicon glyphicon-chevron-left" %> - <%= link_to '', @herbarium, method: :delete, data: { confirm: 'Are you sure?' }, :class => "glyphicon glyphicon-trash" %> + <%= link_to '', @collection, method: :delete, data: { confirm: 'Are you sure?' }, :class => "glyphicon glyphicon-trash" %> diff --git a/app/views/herbaria/index.html.erb b/app/views/collections/index.html.erb similarity index 56% rename from app/views/herbaria/index.html.erb rename to app/views/collections/index.html.erb index d401d76b..d2714c83 100644 --- a/app/views/herbaria/index.html.erb +++ b/app/views/collections/index.html.erb @@ -1,11 +1,11 @@
-

Herbaria

+

Collections

- +
@@ -22,8 +22,8 @@

- <%= link_to new_herbarium_path, class: 'btn btn-default', target: "_blank", title: 'Create a new herbarium entry' do %> + <%= link_to new_collection_path, class: 'btn btn-default', target: "_blank", title: 'Create a new collection record' do %> <% end %> - Create a new herbarium entry + Create a new collection record

diff --git a/app/views/collections/new.html.erb b/app/views/collections/new.html.erb new file mode 100644 index 00000000..56627f25 --- /dev/null +++ b/app/views/collections/new.html.erb @@ -0,0 +1,3 @@ +<%= render 'form', collection: @collection %> + +<%= link_to 'Go to collections index page', collections_path, class: 'btn btn-default' %> diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb new file mode 100644 index 00000000..9c750741 --- /dev/null +++ b/app/views/collections/show.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

+ Name: + <%= @collection.name %> +

+ +

+ Acronym: + <%= @collection.acronym %> +

+ +<%= link_to 'Edit', edit_collection_path(@collection) %> | +<%= link_to 'Back', collections_path %> diff --git a/app/views/herbaria/new.html.erb b/app/views/herbaria/new.html.erb deleted file mode 100644 index aef9085c..00000000 --- a/app/views/herbaria/new.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= render 'form', herbarium: @herbarium %> - -<%= link_to 'Go to herbaria index page', herbaria_path, class: 'btn btn-default' %> diff --git a/app/views/herbaria/show.html.erb b/app/views/herbaria/show.html.erb deleted file mode 100644 index 2684b4f7..00000000 --- a/app/views/herbaria/show.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -

<%= notice %>

- -

- Name: - <%= @herbarium.name %> -

- -

- Acronym: - <%= @herbarium.acronym %> -

- -<%= link_to 'Edit', edit_herbarium_path(@herbarium) %> | -<%= link_to 'Back', herbaria_path %> diff --git a/app/views/individual_searches/_form.html.erb b/app/views/individual_searches/_form.html.erb index 71d780f5..04d6a3fe 100644 --- a/app/views/individual_searches/_form.html.erb +++ b/app/views/individual_searches/_form.html.erb @@ -54,8 +54,8 @@
- <%= f.label :herbarium, 'Herbarium' %>
- <%= f.collection_select :herbarium, Herbarium.order(:name), :name, :name, { include_blank: true }, { class:"form-control" } %> + <%= f.label :collection, 'Collection' %>
+ <%= f.collection_select :collection, Collection.order(:name), :name, :name, { include_blank: true }, { class:"form-control" } %>

diff --git a/app/views/individual_searches/show.html.erb b/app/views/individual_searches/show.html.erb index 3971f58f..a8f3d1e5 100644 --- a/app/views/individual_searches/show.html.erb +++ b/app/views/individual_searches/show.html.erb @@ -18,7 +18,7 @@
- + diff --git a/app/views/individuals/_form.html.erb b/app/views/individuals/_form.html.erb index 124c0fe8..30347ddc 100644 --- a/app/views/individuals/_form.html.erb +++ b/app/views/individuals/_form.html.erb @@ -49,11 +49,11 @@
- <%= f.label :herbarium_id, 'Herbarium' %> - <% if @individual.herbarium %> - <%= link_to '', edit_herbarium_path(@individual.herbarium), { include_blank: true, class: "glyphicon glyphicon-share-alt" } %> + <%= f.label :collection_id, 'Collection' %> + <% if @individual.collection %> + <%= link_to '', edit_collection_path(@individual.collection), { include_blank: true, class: "glyphicon glyphicon-share-alt" } %> <% end %> - <%= f.collection_select(:herbarium_id, Herbarium.all, :id, :name, { include_blank: true }, { class: 'form-control' }) %> + <%= f.collection_select(:collection_id, Collection.all, :id, :name, { include_blank: true }, { class: 'form-control' }) %>
diff --git a/app/views/individuals/index.html.erb b/app/views/individuals/index.html.erb index 14b96986..339adc4b 100644 --- a/app/views/individuals/index.html.erb +++ b/app/views/individuals/index.html.erb @@ -13,7 +13,7 @@
- + diff --git a/app/views/layouts/_navigation_links.html.erb b/app/views/layouts/_navigation_links.html.erb index 97657baf..63f41de5 100644 --- a/app/views/layouts/_navigation_links.html.erb +++ b/app/views/layouts/_navigation_links.html.erb @@ -35,7 +35,7 @@ diff --git a/app/views/taxa/_form.html.erb b/app/views/taxa/_form.html.erb index cf5e2a76..2f0162b0 100644 --- a/app/views/taxa/_form.html.erb +++ b/app/views/taxa/_form.html.erb @@ -153,7 +153,7 @@ - + diff --git a/config/routes.rb b/config/routes.rb index 1527f87e..be1154bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -63,7 +63,7 @@ resources :clusters - resources :herbaria + resources :collections resources :contigs do collection do diff --git a/db/migrate/20220805085607_rename_herbarium_to_collection.rb b/db/migrate/20220805085607_rename_herbarium_to_collection.rb new file mode 100644 index 00000000..c7632d77 --- /dev/null +++ b/db/migrate/20220805085607_rename_herbarium_to_collection.rb @@ -0,0 +1,8 @@ +class RenameHerbariumToCollection < ActiveRecord::Migration[5.2] + def change + rename_table :herbaria, :collections + + rename_column :individual_searches, :herbarium, :collection + rename_column :individuals, :herbarium_id, :collection_id + end +end diff --git a/db/schema.rb b/db/schema.rb index cc632686..b7468384 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_06_03_124135) do +ActiveRecord::Schema.define(version: 2022_08_05_085607) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -86,6 +86,13 @@ t.index ["cluster_id", "project_id"], name: "index_clusters_projects_on_cluster_id_and_project_id" end + create_table "collections", id: :serial, force: :cascade do |t| + t.string "name" + t.string "acronym" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "contig_searches", id: :serial, force: :cascade do |t| t.string "taxon" t.string "specimen" @@ -161,13 +168,6 @@ t.index ["freezer_id", "project_id"], name: "index_freezers_projects_on_freezer_id_and_project_id" end - create_table "herbaria", id: :serial, force: :cascade do |t| - t.string "name" - t.string "acronym" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - create_table "homes", force: :cascade do |t| t.string "title" t.string "subtitle" @@ -191,7 +191,7 @@ t.datetime "updated_at", null: false t.integer "project_id" t.integer "user_id" - t.string "herbarium" + t.string "collection" t.index ["project_id"], name: "index_individual_searches_on_project_id" t.index ["user_id"], name: "index_individual_searches_on_user_id" end @@ -210,7 +210,6 @@ t.text "locality" t.string "latitude_original", limit: 255 t.string "longitude_original", limit: 255 - t.string "elevation_orig", limit: 255 t.string "exposition", limit: 255 t.text "habitat" t.string "substrate", limit: 255 @@ -224,11 +223,12 @@ t.decimal "latitude", precision: 15, scale: 6 t.decimal "longitude", precision: 15, scale: 6 t.boolean "has_issue" - t.integer "herbarium_id" + t.integer "collection_id" t.integer "tissue_id" t.bigint "taxon_id" + t.string "elevation_orig" t.decimal "elevation" - t.index ["herbarium_id"], name: "index_individuals_on_herbarium_id" + t.index ["collection_id"], name: "index_individuals_on_collection_id" t.index ["taxon_id"], name: "index_individuals_on_taxon_id" t.index ["tissue_id"], name: "index_individuals_on_tissue_id" end @@ -651,7 +651,7 @@ add_foreign_key "homes", "logos", column: "main_logo_id" add_foreign_key "individual_searches", "projects" add_foreign_key "individual_searches", "users" - add_foreign_key "individuals", "herbaria" + add_foreign_key "individuals", "collections" add_foreign_key "individuals", "taxa" add_foreign_key "individuals", "tissues" add_foreign_key "lab_racks", "shelves" diff --git a/lib/tasks/update_search_index.rake b/lib/tasks/update_search_index.rake index 99c65f37..068551c7 100644 --- a/lib/tasks/update_search_index.rake +++ b/lib/tasks/update_search_index.rake @@ -24,7 +24,7 @@ namespace :data do task update_search_index: :environment do PgSearch::Multisearch.rebuild(Contig) PgSearch::Multisearch.rebuild(Freezer) - PgSearch::Multisearch.rebuild(Herbarium) + PgSearch::Multisearch.rebuild(Collection) PgSearch::Multisearch.rebuild(Individual) PgSearch::Multisearch.rebuild(Isolate) PgSearch::Multisearch.rebuild(Lab) diff --git a/public/templates/Isolates_Specimen+upload+template.xls b/public/templates/Isolates_Specimen+upload+template.xls index c8c3b556..5a540dab 100755 Binary files a/public/templates/Isolates_Specimen+upload+template.xls and b/public/templates/Isolates_Specimen+upload+template.xls differ diff --git a/spec/factories/herbaria.rb b/spec/factories/collections.rb similarity index 97% rename from spec/factories/herbaria.rb rename to spec/factories/collections.rb index f032b434..bc46efdd 100644 --- a/spec/factories/herbaria.rb +++ b/spec/factories/collections.rb @@ -23,7 +23,7 @@ require 'faker' FactoryBot.define do - factory :herbarium do |h| + factory :collection do |h| h.name { Faker::Lorem.word } h.acronym { Faker::Hacker.abbreviation } end diff --git a/spec/factories/individual_searches.rb b/spec/factories/individual_searches.rb index 561b9116..64161fd6 100644 --- a/spec/factories/individual_searches.rb +++ b/spec/factories/individual_searches.rb @@ -28,7 +28,7 @@ is.has_issue { Faker::Number.between(from: 0, to: 2) } is.has_problematic_location { Faker::Number.between(from: 0, to: 2) } is.has_taxon { Faker::Number.between(from: 0, to: 2) } - is.herbarium { Faker::Lorem.word } + is.collection { Faker::Lorem.word } is.taxon { Faker::Lorem.word } is.title { Faker::Lorem.word } end diff --git a/spec/models/herbarium_spec.rb b/spec/models/collection_spec.rb similarity index 94% rename from spec/models/herbarium_spec.rb rename to spec/models/collection_spec.rb index 38332be0..b81158ab 100644 --- a/spec/models/herbarium_spec.rb +++ b/spec/models/collection_spec.rb @@ -22,8 +22,8 @@ require 'rails_helper' -RSpec.describe Herbarium do - subject { FactoryBot.create(:herbarium) } +RSpec.describe Collection do + subject { FactoryBot.create(:collection) } it "is valid with valid attributes" do should be_valid diff --git a/spec/models/individual_spec.rb b/spec/models/individual_spec.rb index a8bcadf2..c86f769c 100644 --- a/spec/models/individual_spec.rb +++ b/spec/models/individual_spec.rb @@ -37,8 +37,8 @@ should belong_to(:taxon) end - it "belongs to a herbarium" do - should belong_to(:herbarium) + it "belongs to a collection" do + should belong_to(:collection) end it "belongs to a tissue" do
Name
Specimen ID Associated TaxonHerbariumCollection Latitude Longitude Last updated
Specimen ID Parent TaxonHerbariumCollection Collector Collector's Field Number Last updated
Specimen ID Associated TaxonHerbariumCollection Collector Collector's Field Number Last updated