Skip to content

Commit

Permalink
use new import_template.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Rossi committed Sep 27, 2016
1 parent 57eff3c commit c2e5b33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/modules/csv_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def find_genus value
genera[value] or raise CsvConversionError, error_message
end

{
CONVERSIONS = {
"User Name" => proc { |value| @report.user = find_user(value) },
"Own Agency?" => proc { |value| answer("own_organisation", value) },
"Country of Discovery" => proc { |value| answer("country_of_discovery", value) },
Expand Down Expand Up @@ -136,7 +136,13 @@ def find_genus value
"Punishment Successful?" => proc { |value| answer("punishment", value) },
"Other Illegal Activities" => proc { |value| answer("illegal_activities", value.split(",")) },
"Man-made disturbances" => proc { |value| answer("proximity", value.split(",")) }
}.each do |header, method|
}

CONVERSIONS.each do |header, method|
self.send(:define_method, header, method)
end

def self.columns
CONVERSIONS.keys
end
end
4 changes: 4 additions & 0 deletions lib/modules/csv_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ def self.import(csv_path)
{successful: true, reports: reports}
end
end

def self.generate_template
CsvConverter.columns.join(",")
end
end
2 changes: 1 addition & 1 deletion public/template.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ID;Report Status;User Name;Agency;Collaboration?;Timestamp;Country of Discovery;Region of Discovery;Date of Discovery;GPS Location;Type of Location;Ape Status;Ape (Genus);Species/Subspecies;Intended Use;Photo;Age;Gender;Last Location;Country of Origin;Condition;Identifiers;Name;Bone Qty;Foot/Hand Qty;Genitalia Qty;Hair Qty;Meat Kg;Skin Qty;Skull Qty;Confiscation?;Arrests Made?;Prosecution?;Prosecution Successful?;Punishment Successful?;Other Illegal Activities;Man-made disturbances
User Name,Own Agency?,Country of Discovery,Region of Discovery,Date of Discovery,GPS Location,Type of Location,Live Ape (Genus),Live Species/Subspecies,Live Intended Use,Live Age,Live Gender,Live Last Location,Live Country of Origin,Live Condition,Live Ape For Sale,Live Sale Price,Live Identifiers,Live Name,Dead Ape (Genus),Dead Species/Subspecies,Dead Intended Use,Dead Age,Dead Gender,Dead Last Location,Dead Country of Origin,Dead Condition,Dead Identifiers,Dead Name,Body Parts (Genus),Bone (Femur) Qty,Bone (Humerus) Qty,Foot Qty,Hand Qty,Skull Qty,Torso Qty,Confiscation?,Arrests Made?,Prosecution?,Prosecution Successful?,Punishment Successful?,Other Illegal Activities,Man-made disturbances

0 comments on commit c2e5b33

Please sign in to comment.