Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Research pages fetching R4D docs from the R4D API #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 78 additions & 4 deletions devtracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@

# get the funded projects Count from the API
fundedProjectsCount = get_funded_project_count(n)

# get the R4D docs count from the R4D API
begin
r4dDocs = r4DApiDocFetch(n) || ''
r4dDocsCount = r4dDocs.count
rescue
r4dDocsCount = 0
end

erb :'projects/summary',
:layout => :'layouts/layout',
Expand All @@ -313,7 +321,8 @@
fundedProjectsCount: fundedProjectsCount,
fundingProjectsCount: fundingProjectsCount,
#projectBudget: projectBudget,
projectSectorGraphData: projectSectorGraphData
projectSectorGraphData: projectSectorGraphData,
r4dDocsCount: r4dDocsCount
}
end

Expand All @@ -331,14 +340,23 @@

# get the funded projects Count from the API
fundedProjectsCount = get_funded_project_count(n)

# get the R4D docs count from the R4D API
begin
r4dDocs = r4DApiDocFetch(n) || ''
r4dDocsCount = r4dDocs.count
rescue
r4dDocsCount = 0
end

erb :'projects/documents',
:layout => :'layouts/layout',
:locals => {
project: project,
countryOrRegion: countryOrRegion,
fundedProjectsCount: fundedProjectsCount,
fundingProjectsCount: fundingProjectsCount
fundingProjectsCount: fundingProjectsCount,
r4dDocsCount: r4dDocsCount
}
end

Expand All @@ -362,6 +380,14 @@

# get the funded projects Count from the API
fundedProjectsCount = get_funded_project_count(n)

# get the R4D docs count from the R4D API
begin
r4dDocs = r4DApiDocFetch(n) || ''
r4dDocsCount = r4dDocs.count
rescue
r4dDocsCount = 0
end

erb :'projects/transactions',
:layout => :'layouts/layout',
Expand All @@ -371,7 +397,8 @@
transactions: transactions,
projectYearWiseBudgets: projectYearWiseBudgets,
fundedProjectsCount: fundedProjectsCount,
fundingProjectsCount: fundingProjectsCount
fundingProjectsCount: fundingProjectsCount,
r4dDocsCount: r4dDocsCount
}
end

Expand All @@ -391,6 +418,14 @@
# get the funded projects from the API
fundedProjectsData = get_funded_project_details(n)

# get the R4D docs count from the R4D API
begin
r4dDocs = r4DApiDocFetch(n) || ''
r4dDocsCount = r4dDocs.count
rescue
r4dDocsCount = 0
end

erb :'projects/partners',
:layout => :'layouts/layout',
:locals => {
Expand All @@ -399,7 +434,46 @@
fundedProjects: fundedProjectsData['results'],
fundedProjectsCount: fundedProjectsData['count'],
fundingProjects: fundingProjects,
fundingProjectsCount: fundingProjectsData['count']
fundingProjectsCount: fundingProjectsData['count'],
r4dDocsCount: r4dDocsCount
}
end

#Project research page
get '/projects/:proj_id/research/?' do |n|
n = sanitize_input(n,"p")
# get the project data from the API
project = get_h1_project_details(n)

#get the country/region data from the API
countryOrRegion = get_country_or_region(n)

#get total project budget and spend Data
#projectBudget = get_project_budget(n)

#get project sectorwise graph data
projectSectorGraphData = get_project_sector_graph_data(n)

# get the funding projects Count from the API
fundingProjectsCount = get_funding_project_count(n)

# get the funded projects Count from the API
fundedProjectsCount = get_funded_project_count(n)

# get the R4D docs count from the R4D API
r4dDocs = r4DApiDocFetch(n) || ''
r4dDocsCount = r4dDocs.count

erb :'projects/research',
:layout => :'layouts/layout',
:locals => {
project: project,
countryOrRegion: countryOrRegion,
fundedProjectsCount: fundedProjectsCount,
fundingProjectsCount: fundingProjectsCount,
projectSectorGraphData: projectSectorGraphData,
r4dDocsCount: r4dDocsCount,
r4dDocs: r4dDocs
}
end

Expand Down
7 changes: 4 additions & 3 deletions views/partials/_projects-header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
<li <%= active=="summary" ? "class='active'" : ""%>><a href="/projects/<%=project['iati_identifier']%>">Summary</a></li>
<li <%= active=="documents" ? "class='active'" : ""%>><a href="/projects/<%=project['iati_identifier']%>/documents">Documents (<%= project['document_links'].count %>)</a></li>
<li <%= active=="transactions" ? "class='active'" : ""%>><a href="/projects/<%=project['iati_identifier']%>/transactions">Transactions</a></li>
<% if fundedProjectsCount > 0 || fundingProjectsCount > 0 then %>
<% if r4dDocsCount > 0 then %>
<li <%= active=="research" ? "class='active'" : ""%>><a href="/projects/<%=project['iati_identifier']%>/research">Research (<%= r4dDocsCount %>)</a></li>
<% end %>
<% if fundedProjectsCount > 0 || fundingProjectsCount > 0 then %>
<li <%= active=="partners" ? "class='active'" : ""%>><a href="/projects/<%=project['iati_identifier']%>/partners">Partners</a></li>
<% end %>

<!-- TODO: bring back in r4dDocs element -->
</ul>
</nav>
</div>
Expand Down
2 changes: 1 addition & 1 deletion views/projects/documents.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :active => "documents"} %>
<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :r4dDocsCount => r4dDocsCount, :active => "documents"} %>

<div class="row">
<div class="twelve columns summary">
Expand Down
2 changes: 1 addition & 1 deletion views/projects/partners.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- title: Development Tracker -->

<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :active => "partners"} %>
<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :r4dDocsCount => r4dDocsCount, :active => "partners"} %>

<% if fundingProjectsCount > 0 then %>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
---
published: "true"
title: Development Tracker

---

<%= partial "partials/projects-header", :locals => { :project => project, :active => "r4dDocs", :has_funded_projects => has_funded_projects} %>
<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :r4dDocsCount => r4dDocsCount, :active => "research"} %>

<div class="row">
<div class="twelve columns summary">
<% r4dDocs = r4DApiDocFetch(project['iatiId']) || '' %>
<% #r4dDocs = r4DApiDocFetch(project['iatiId']) || '' %>
<%if !r4dDocs.nil? && r4dDocs.length > 0 %>
<p>This project has supported the following research projects and/or publications</p>
<% r4dDocs.each do |s| %>
Expand Down
2 changes: 1 addition & 1 deletion views/projects/summary.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :active => "summary"} %>
<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :r4dDocsCount => r4dDocsCount, :active => "summary"} %>

<div class="row">
<div class="twelve columns">
Expand Down
2 changes: 1 addition & 1 deletion views/projects/transactions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Development Tracker
--- -->

<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :active => "transactions"} %>
<%= erb :'partials/_projects-header', :locals => { :project => project, :countryOrRegion => countryOrRegion, :fundedProjectsCount => fundedProjectsCount, :fundingProjectsCount => fundingProjectsCount, :r4dDocsCount => r4dDocsCount, :active => "transactions"} %>

<%# ------------------------------------------------------------------------ %>
<%# B U D G E T S T A B L E %>
Expand Down