Skip to content

Commit

Permalink
Merge pull request #455 from PEM-Humboldt/release/2.11.0
Browse files Browse the repository at this point in the history
release/2.11.0
  • Loading branch information
cazapatamar authored May 30, 2024
2 parents 4521f69 + 8a75466 commit 0316151
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 113 deletions.
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BioModelos v2.10.3
# BioModelos v2.11.0

[BioModelos](http://biomodelos.humboldt.org.co) is a web app that facilitates the generation, validation and consultation of hypothesis of species distribution for the continental biodiversity of Colombia. As such, it provides tools to (1) improve existing species distribution models (SDMs) by integrating expert's opinion, (2) generate expert maps and (3) publish SDMs. Our objective is to provide freely and openly access to the most up to date information on species distributions, validated by a large network of researchers, to support national environmental decision making processes and research.

Expand Down
9 changes: 0 additions & 9 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ def show
@group = Group.find(params[:id])
@tasks = Task.where(:group_id => @group.id)
@species_ids = GroupsSpecies.where(:group_id => @group.id, :groups_species_state_id => 1)
#@species_with_tasks_pending = @tasks.select{|x| x.task_state_id == 1}.map{|t| [Species.find_name(t.species_id.to_s),t.species_id]}.uniq
@models_approved = 0
# @species_with_tasks.each do |species|
# approved_by_species = @tasks.select{|x| x.species_id == species[1] && x.task_type_id == 4}
# approved_by_species_done = @tasks.select{|x| x.species_id == species[1] && x.task_type_id == 4 && x.task_state_id == 2}
# if approved_by_species.size > 0 && approved_by_species.size == approved_by_species_done.size
# @models_approved = @models_approved + 1
# end
# end
@group_members_number = GroupsUser.where(:group_id => @group.id, :groups_users_state_id => 1).count
@group_admins = GroupsUser.where(:group_id => @group.id, :groups_users_state_id => 1, :is_admin => true).joins(:user).order('users.name')
@groups_species = GroupsSpecies.new
Expand Down
135 changes: 69 additions & 66 deletions app/models/species.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
class Species
include HTTParty
format :json
base_uri BASE_URI + '/species'
# has_many :tasks
include HTTParty
format :json
base_uri BASE_URI + '/species'

def self.find_name(taxID)
res = JSON.parse(get('/' + taxID.to_s).body)
if !res.blank?
res = res[0]["acceptedNameUsage"]
else
res = ""
end
return res
end
def self.find_name(taxID)
res = JSON.parse(get('/' + taxID.to_s).body)
if !res.blank?
res = res[0]["acceptedNameUsage"]
else
res = ""
end
return res
end

def self.find_names(taxIDList)
res = JSON.parse(get('?speciesIn=' + taxIDList.join(',')).body)
return res
end
def self.find_names(taxIDList)
if taxIDList.empty?
return []
end

def self.records_number(taxID)
JSON.parse(get('/' + taxID.to_s).body)[0]["totalRecords"]
end
res = JSON.parse(get('?speciesIn=' + taxIDList.join(',')).body)
return res
end

def self.info(taxID)
JSON.parse(get('/' + taxID.to_s).body)
end
def self.records_number(taxID)
JSON.parse(get('/' + taxID.to_s).body)[0]["totalRecords"]
end

def self.records(taxID)
JSON.parse(get('/records/' + taxID.to_s).body)
end
def self.info(taxID)
JSON.parse(get('/' + taxID.to_s).body)
end

def self.group_records(taxID)
JSON.parse(get('/records/group/' + taxID.to_s).body)
end
def self.records(taxID)
JSON.parse(get('/records/' + taxID.to_s).body)
end

def self.group_records(taxID)
JSON.parse(get('/records/group/' + taxID.to_s).body)
end

def self.filter(params)
url = "?"
Expand Down Expand Up @@ -64,42 +67,42 @@ def self.filter(params)
JSON.parse(get(URI.escape(url)).body)
end

def self.search(params)
url = "/search"
if params[:query]
url += "/" + params[:query] + "?"
end
if params[:bmClass1]
url += "&bmClass1=" + params[:bmClass1]
end
if params[:bmClass2]
url += "&bmClass2=" + params[:bmClass2]
end
if params[:bmClass3]
url += "&bmClass3=" + params[:bmClass3]
end
if params[:bmClass4]
url += "&bmClass4=" + params[:bmClass4]
end
if params[:bmClass5]
url += "&bmClass5=" + params[:bmClass5]
end
if params[:bmClass6]
url += "&bmClass6=" + params[:bmClass6]
end
if params[:bmClass7]
url += "&bmClass7=" + params[:bmClass7]
end
if params[:endemic]
url += "&endemic=" + params[:endemic]
end
if params[:invasive]
url += "&invasive=" + params[:invasive]
end
if params[:endangered]
url += "&endangered=" + params[:endangered]
end
def self.search(params)
url = "/search"
if params[:query]
url += "/" + params[:query] + "?"
end
if params[:bmClass1]
url += "&bmClass1=" + params[:bmClass1]
end
if params[:bmClass2]
url += "&bmClass2=" + params[:bmClass2]
end
if params[:bmClass3]
url += "&bmClass3=" + params[:bmClass3]
end
if params[:bmClass4]
url += "&bmClass4=" + params[:bmClass4]
end
if params[:bmClass5]
url += "&bmClass5=" + params[:bmClass5]
end
if params[:bmClass6]
url += "&bmClass6=" + params[:bmClass6]
end
if params[:bmClass7]
url += "&bmClass7=" + params[:bmClass7]
end
if params[:endemic]
url += "&endemic=" + params[:endemic]
end
if params[:invasive]
url += "&invasive=" + params[:invasive]
end
if params[:endangered]
url += "&endangered=" + params[:endangered]
end

JSON.parse(get(URI.escape(url)).body)
end
JSON.parse(get(URI.escape(url)).body)
end
end
13 changes: 5 additions & 8 deletions app/views/info/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,23 @@
</div>
<div class="atlasSec">
<h4><%= t('biomodelos.info.tituloatlas') %></h4>
<% if Date.parse('2024-05-24') > Date.today %>
<p style="max-width:700px">Fe de erratas: las descargas del Atlas de aves endémicas que se hicieron antes del 23 de abril de 2024 presentan un error en la fotografía de la especie <i>Phylloscartes lanyoni</i>. En esta nueva versión se corrige dicho error.</p>
<% end %>
<a href="/atlas/AvesEndemicas.pdf" target="_blank" class="cajathumb">
<a href="https://repository.humboldt.org.co/entities/publication/e691ab88-055d-4604-b918-51287678ae6b" target="_blank" class="cajathumb">
<%= image_tag("EndemicasP.png") %>
<p>+</p>
</a>
<a href="/atlas/GrandesRoedores.pdf" target="_blank" class="cajathumb">
<a href="https://repository.humboldt.org.co/entities/publication/e71ba7c1-d164-4329-a0cf-88a0d5f2cef9" target="_blank" class="cajathumb">
<%= image_tag("roedores.png") %>
<p>+</p>
</a>
<a href="/atlas/Anolis.pdf" target="_blank" class="cajathumb">
<a href="https://repository.humboldt.org.co/entities/publication/f26ed47d-457f-4132-b609-ceeff11bdc42" target="_blank" class="cajathumb">
<%= image_tag("AnolisP.png") %>
<p>+</p>
</a>
<a href="/atlas/Primates.pdf" target="_blank" class="cajathumb">
<a href="https://repository.humboldt.org.co/entities/publication/66de7ffe-c050-4395-bf63-f674ebaf7326" target="_blank" class="cajathumb">
<%= image_tag("PrimatesP.png") %>
<p>+</p>
</a>
<a href="/atlas/Zamias.pdf" target="_blank" class="cajathumb">
<a href="https://repository.humboldt.org.co/entities/publication/ea76221c-4e77-40a1-ab07-5e1fcb716f69" target="_blank" class="cajathumb">
<%= image_tag("ZamiasP.png") %>
<p>+</p>
</a>
Expand Down
58 changes: 29 additions & 29 deletions app/views/tasks/_new_tasks_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<%= simple_form_for @task, :url => {:controller => "tasks", :action => "add_tasks"}, :method => :post, :remote => true do |f| %>
<%= f.error_notification %>
<%= f.hidden_field :group_id, value: @group.id %>
<p><%= t('biomodelos.tasks.new_task') %></p>
<% if current_group_user.is_admin %>
<%= f.select :user_id, options_from_collection_for_select(GroupsUser.where(:group_id => @group.id, :groups_users_state_id => 1).joins(:user).order('users.name'), 'user_id', 'user_name'), include_blank: t('biomodelos.tasks.choose_expert') %>
<% else %>
<%= f.hidden_field :user_id, value: current_user.id %>
<% end %>
<%= f.select :species_id, options_for_select(Species.find_names(@species_ids.map{|t| t.species_id}.uniq).map{|s| [s["acceptedNameUsage"], s["taxID"]]}), :include_blank => t('biomodelos.tasks.choose_species') %>
<p class="tarea"><%= t('biomodelos.tasks.choose_tasks') %></p>
<div id="chkBoxTask">
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.records_task_tt') %>">
<%= check_box_tag :records_task, 1, checked:true %>
<%= image_tag("regperfil.png") %>
</label>
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.edition_task_tt') %>">
<%= check_box_tag :edition_task, 2, checked:true %>
<%= image_tag("penperfil.png") %>
</label>
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.covers_task_tt') %>">
<%= check_box_tag :eco_task, 3, checked:true %>
<%= image_tag("veicon2.png") %>
</label>
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.validation_task_tt') %>">
<%= check_box_tag :approval_task, 4, checked:true %>
<%= image_tag("aprobicon.png") %>
</label>
<%= f.button :submit, :value => t('biomodelos.tasks.submit_btn'), :class => 'btngen', data: { disable_with: t('biomodelos.tasks.submit_btn') }%>
</div>
<%= f.error_notification %>
<%= f.hidden_field :group_id, value: @group.id %>
<p><%= t('biomodelos.tasks.new_task') %></p>
<% if current_group_user.is_admin %>
<%= f.select :user_id, options_from_collection_for_select(GroupsUser.where(:group_id => @group.id, :groups_users_state_id => 1).joins(:user).order('users.name'), 'user_id', 'user_name'), include_blank: t('biomodelos.tasks.choose_expert') %>
<% else %>
<%= f.hidden_field :user_id, value: current_user.id %>
<% end %>
<%= f.select :species_id, options_for_select(Species.find_names(@species_ids.map{|t| t.species_id}.uniq).map{|s| [s["acceptedNameUsage"], s["taxID"]]}), :include_blank => t('biomodelos.tasks.choose_species') %>
<p class="tarea"><%= t('biomodelos.tasks.choose_tasks') %></p>
<div id="chkBoxTask">
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.records_task_tt') %>">
<%= check_box_tag :records_task, 1, checked:true %>
<%= image_tag("regperfil.png") %>
</label>
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.edition_task_tt') %>">
<%= check_box_tag :edition_task, 2, checked:true %>
<%= image_tag("penperfil.png") %>
</label>
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.covers_task_tt') %>">
<%= check_box_tag :eco_task, 3, checked:true %>
<%= image_tag("veicon2.png") %>
</label>
<label class="lblvisual" rel="tooltip" title="<%= t('biomodelos.tasks.validation_task_tt') %>">
<%= check_box_tag :approval_task, 4, checked:true %>
<%= image_tag("aprobicon.png") %>
</label>
<%= f.button :submit, :value => t('biomodelos.tasks.submit_btn'), :class => 'btngen', data: { disable_with: t('biomodelos.tasks.submit_btn') }%>
</div>
<% end %>

0 comments on commit 0316151

Please sign in to comment.