Skip to content

Commit

Permalink
feat: Adding research notes to ASCOR assessment model
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomas committed Nov 7, 2023
1 parent f927a16 commit 54c46e6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
7 changes: 3 additions & 4 deletions app/admin/ascor/assessments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
column :country, sortable: 'ascor_countries.name'
column :assessment_date
column :publication_date
column :notes

actions
end
Expand All @@ -29,7 +28,7 @@
row :country
row :assessment_date
row :publication_date
row :notes
row 'Research Notes', &:notes
row :created_at
row :updated_at
end
Expand All @@ -53,7 +52,7 @@
f.input :country, as: :select, collection: ASCOR::Country.all.order(:name)
f.input :assessment_date, as: :datepicker
f.input :publication_date, as: :datepicker
f.input :notes
f.input :notes, label: 'Research Notes'
end

f.has_many :results, allow_destroy: true, heading: false do |ff|
Expand Down Expand Up @@ -91,7 +90,7 @@
controller.assessment_results[[resource.id, indicator.id]]&.first&.year
end
end
column :notes
column 'Research Notes', &:notes
end

controller do
Expand Down
6 changes: 5 additions & 1 deletion app/assets/stylesheets/tpi/pages/ascor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ $see-more-width-tablet: 130px;

.country-assessment {
margin-top: 60px;
margin-bottom: 60px;
margin-bottom: 30px;

&__pillar {
outline: solid 1px $grey-lighter-medium;
Expand Down Expand Up @@ -510,6 +510,10 @@ $see-more-width-tablet: 130px;
}
}

.notes {
margin-bottom: 30px;
}

.contacts {
width: 100%;
height: 380px;
Expand Down
2 changes: 1 addition & 1 deletion app/services/csv_import/ascor_assessments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def import
assessment.country = countries[row[:country]].first if row.header?(:country)
assessment.assessment_date = assessment_date(row) if row.header?(:assessment_date)
assessment.publication_date = publication_date(row) if row.header?(:publication_date)
assessment.notes = row[:notes] if row.header?(:notes)
assessment.notes = row[:research_notes] if row.header?(:research_notes)

was_new_record = assessment.new_record?

Expand Down
11 changes: 11 additions & 0 deletions app/views/tpi/ascor/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,16 @@
</section>
<% end %>

<div class="container notes">
<% if @assessment.notes.present? %>
<h6>Research notes:</h6>
<p>
<%= @assessment.notes %>
</p>
<% else %>
<span style="display: inline-block"></span>
<% end %>
</div>

<%= render 'contact' %>
</div>
6 changes: 3 additions & 3 deletions db/seeds/tpi/ascor_assessments.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/commands/csv_data_upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@
indicator_1 = assessment.results.joins(:indicator).find_by ascor_assessment_indicators: {code: 'EP.1.a'}
indicator_2 = assessment.results.joins(:indicator).find_by ascor_assessment_indicators: {code: 'EP.1.a.i'}

expect(assessment.notes).to be_nil
expect(assessment.notes).to eq('Research notes')
expect(assessment.publication_date).to eq(Date.new(2023, 12))
expect(assessment.assessment_date).to eq(Date.new(2023, 10, 30))
expect(indicator_1.answer).to eq('Yes')
Expand Down
6 changes: 3 additions & 3 deletions spec/support/fixtures/files/ascor_assessments.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Id,Assessment Date,Publication Date,Country Id,Country,area EP.1,indicator EP.1.a,indicator EP.1.b,indicator EP.1.c,source indicator EP.1.a,source metric EP.1.a.i,source metric EP.1.a.ii,source indicator EP.1.b,source indicator EP.1.c,year metric EP.1.a.i,year metric EP.1.a.ii
,10/30/23,2023-12,,United States,No,No,No,No,https://zenodo.org/record/7727475,,,https://1p5ndc-pathways.climateanalytics.org/,,,
,10/30/23,2023-12,,Japan,Partial,Yes,No,No,https://zenodo.org/record/7727476,,,https://1p5ndc-pathways.climateanalytics.org/,,2010,
Id,Assessment Date,Publication Date,Country Id,Country,area EP.1,indicator EP.1.a,indicator EP.1.b,indicator EP.1.c,source indicator EP.1.a,source metric EP.1.a.i,source metric EP.1.a.ii,source indicator EP.1.b,source indicator EP.1.c,year metric EP.1.a.i,year metric EP.1.a.ii,Research notes
,10/30/23,2023-12,,United States,No,No,No,No,https://zenodo.org/record/7727475,,,https://1p5ndc-pathways.climateanalytics.org/,,,,
,10/30/23,2023-12,,Japan,Partial,Yes,No,No,https://zenodo.org/record/7727476,,,https://1p5ndc-pathways.climateanalytics.org/,,2010,,Research notes

0 comments on commit 54c46e6

Please sign in to comment.