Skip to content

Commit

Permalink
rename orangutan
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Rossi committed Sep 27, 2016
1 parent 003eb9c commit 67eea57
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/views/reports/search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="form__group">
<%= label_tag :genus, 'Ape (Genus)' %>
<div class="form__field">
<%= select_tag :genus, options_for_select(["Bonobo (Pan)", "Chimpanzee (Pan)", "Gorilla (Gorilla)", "Orang-utan (Pongo)", "Unknown"]), multiple: true, class: 'select2' %>
<%= select_tag :genus, options_for_select(["Bonobo (Pan)", "Chimpanzee (Pan)", "Gorilla (Gorilla)", "Orangutan (Pongo)", "Unknown"]), multiple: true, class: 'select2' %>
</div>
</div>

Expand Down
12 changes: 6 additions & 6 deletions config/questionnaire/pages/dead.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Bonobo (Pan)",
"Chimpanzee (Pan)",
"Gorilla (Gorilla)",
"Orang-utan (Pongo)",
"Orangutan (Pongo)",
"Unknown"
]
},
Expand Down Expand Up @@ -40,14 +40,14 @@
"orangutan_species_dead": {
"id": "species_subspecies_dead",
"type": "subspecies",
"show_if": {"question": "genus_dead", "answer": "Orang-utan (Pongo)"},
"show_if": {"question": "genus_dead", "answer": "Orangutan (Pongo)"},
"tooltip": "Please do not guess the subspecies; input only on surety, ideally confirmed by DNA analysis.",
"question": "Confirmation of Species/subspecies (optional)",
"answers": [
"Bornean orang-utan (Pongo pygmaeus pygmaeus) – northwest populations",
"Bornean orang-utan (Pongo pygmaeus morio) – east populations",
"Bornean orang-utan (Pongo pygmaeus wurmbii) – southwest populations",
"Sumatran orang-utan (Pongo abelii)"
"Bornean orangutan (Pongo pygmaeus pygmaeus) – northwest populations",
"Bornean orangutan (Pongo pygmaeus morio) – east populations",
"Bornean orangutan (Pongo pygmaeus wurmbii) – southwest populations",
"Sumatran orangutan (Pongo abelii)"
]
},
"intended_use_dead": {
Expand Down
12 changes: 6 additions & 6 deletions config/questionnaire/pages/live.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Bonobo (Pan)",
"Chimpanzee (Pan)",
"Gorilla (Gorilla)",
"Orang-utan (Pongo)",
"Orangutan (Pongo)",
"Unknown"
]
},
Expand Down Expand Up @@ -40,14 +40,14 @@
"orangutan_species_live": {
"id": "species_subspecies_live",
"type": "subspecies",
"show_if": {"question": "genus_live", "answer": "Orang-utan (Pongo)"},
"show_if": {"question": "genus_live", "answer": "Orangutan (Pongo)"},
"tooltip": "Please do not guess the subspecies; input only on surety, ideally confirmed by DNA analysis.",
"question": "Confirmation of Species/subspecies (optional)",
"answers": [
"Bornean orang-utan (Pongo pygmaeus pygmaeus) – northwest populations",
"Bornean orang-utan (Pongo pygmaeus morio) – east populations",
"Bornean orang-utan (Pongo pygmaeus wurmbii) – southwest populations",
"Sumatran orang-utan (Pongo abelii)"
"Bornean orangutan (Pongo pygmaeus pygmaeus) – northwest populations",
"Bornean orangutan (Pongo pygmaeus morio) – east populations",
"Bornean orangutan (Pongo pygmaeus wurmbii) – southwest populations",
"Sumatran orangutan (Pongo abelii)"
]
},
"intended_use_live": {
Expand Down
6 changes: 3 additions & 3 deletions config/questionnaire/pages/parts.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Bonobo (Pan)",
"Chimpanzee (Pan)",
"Gorilla (Gorilla)",
"Orang-utan (Pongo)",
"Orangutan (Pongo)",
"Unknown"
]
},
Expand Down Expand Up @@ -55,8 +55,8 @@
},
"parts_orangutan": {
"id": "parts_orangutan",
"question": "Orang-utan body parts found / Quantity",
"show_if": {"question": "genus_parts", "answer": "Orang-utan (Pongo)"},
"question": "Orangutan body parts found / Quantity",
"show_if": {"question": "genus_parts", "answer": "Orangutan (Pongo)"},
"type": "body_parts",
"parts": [
{"id": "bone_femur", "question": "Bone (Femur)", "type": "numeric"},
Expand Down
41 changes: 41 additions & 0 deletions db/migrate/20160927163754_rename_orangutan.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class RenameOrangutan < ActiveRecord::Migration
def change
Expertise
.where(name: "Orang-utan (Pongo)")
.update_all(name: "Orangutan (Pongo)")

Report.all.each do |report|
if live_apes = report.data.dig("answers", "live")
report.data["answers"]["live"] = live_apes.map do |ape|
if ape.dig("genus_live", "selected") == "Orang-utan (Pongo)"
ape["genus_live"]["selected"] = "Orangutan (Pongo)"
end

ape
end
end

if dead_apes = report.data.dig("answers", "dead")
report.data["answers"]["dead"] = dead_apes.map do |ape|
if ape.dig("genus_dead", "selected") == "Orang-utan (Pongo)"
ape["genus_dead"]["selected"] = "Orangutan (Pongo)"
end

ape
end
end

if dead_apes = report.data.dig("answers", "body_parts")
report.data["answers"]["body_parts"] = dead_apes.map do |ape|
if orangutan_index = ape.dig("genus_parts", "selected").index("Orang-utan (Pongo)")
ape["genus_parts"]["selected"][orangutan_index] = "Orangutan (Pongo)"
end

ape
end
end

report.save
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160912103105) do
ActiveRecord::Schema.define(version: 20160927163754) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
roles = ["admin", "validator", "provider"]
roles.each { |r| Role.where(name: r).first_or_create }

expertise = ["Bonobo (Pan)", "Gorilla (Gorilla)", "Chimpanzee (Pan)", "Orang-utan (Pongo)",
expertise = ["Bonobo (Pan)", "Gorilla (Gorilla)", "Chimpanzee (Pan)", "Orangutan (Pongo)",
"West Africa", "Central Africa", "East Africa", "Southeast Asia", "Rest of the World"]
expertise.each { |e| Expertise.where(name: e).first_or_create }

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/csv_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def self.to_db_name genus
"bonobo (pan)" => "bonobo",
"chimpanzee (pan)" => "chimpanzee",
"gorilla (gorilla)" => "gorilla",
"orang-utan (pongo)" => "orangutan",
"orangutan (pongo)" => "orangutan",
"unknown" => "unknown"
}

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/csv_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def find_genus value
"Bonobo (Pan)" => "bonobo",
"Chimpanzee (Pan)" => "chimpanzee",
"Gorilla (Gorilla)" => "gorilla",
"Orang-utan (Pongo)" => "orangutan",
"Orangutan (Pongo)" => "orangutan",
"Unknown" => "unknown"
}

Expand Down

0 comments on commit 67eea57

Please sign in to comment.