diff --git a/devtracker.rb b/devtracker.rb index d84de4cf..49ed4533 100644 --- a/devtracker.rb +++ b/devtracker.rb @@ -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', @@ -313,7 +321,8 @@ fundedProjectsCount: fundedProjectsCount, fundingProjectsCount: fundingProjectsCount, #projectBudget: projectBudget, - projectSectorGraphData: projectSectorGraphData + projectSectorGraphData: projectSectorGraphData, + r4dDocsCount: r4dDocsCount } end @@ -331,6 +340,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/documents', :layout => :'layouts/layout', @@ -338,7 +355,8 @@ project: project, countryOrRegion: countryOrRegion, fundedProjectsCount: fundedProjectsCount, - fundingProjectsCount: fundingProjectsCount + fundingProjectsCount: fundingProjectsCount, + r4dDocsCount: r4dDocsCount } end @@ -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', @@ -371,7 +397,8 @@ transactions: transactions, projectYearWiseBudgets: projectYearWiseBudgets, fundedProjectsCount: fundedProjectsCount, - fundingProjectsCount: fundingProjectsCount + fundingProjectsCount: fundingProjectsCount, + r4dDocsCount: r4dDocsCount } end @@ -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 => { @@ -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 diff --git a/views/partials/_projects-header.html.erb b/views/partials/_projects-header.html.erb index 4034036b..e92d9444 100755 --- a/views/partials/_projects-header.html.erb +++ b/views/partials/_projects-header.html.erb @@ -37,11 +37,12 @@
  • >Summary
  • >Documents (<%= project['document_links'].count %>)
  • >Transactions
  • - <% if fundedProjectsCount > 0 || fundingProjectsCount > 0 then %> + <% if r4dDocsCount > 0 then %> +
  • >Research (<%= r4dDocsCount %>)
  • + <% end %> + <% if fundedProjectsCount > 0 || fundingProjectsCount > 0 then %>
  • >Partners
  • <% end %> - - diff --git a/views/projects/documents.html.erb b/views/projects/documents.html.erb index e541fa1d..454cefa3 100644 --- a/views/projects/documents.html.erb +++ b/views/projects/documents.html.erb @@ -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"} %>
    diff --git a/views/projects/partners.html.erb b/views/projects/partners.html.erb index 2e4c21ba..29f268b5 100755 --- a/views/projects/partners.html.erb +++ b/views/projects/partners.html.erb @@ -1,6 +1,6 @@ -<%= 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 %>
    diff --git a/views/projects/r4dDocs.html.erb b/views/projects/research.html.erb similarity index 79% rename from views/projects/r4dDocs.html.erb rename to views/projects/research.html.erb index b082517a..493cdec7 100644 --- a/views/projects/r4dDocs.html.erb +++ b/views/projects/research.html.erb @@ -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"} %>
    - <% r4dDocs = r4DApiDocFetch(project['iatiId']) || '' %> + <% #r4dDocs = r4DApiDocFetch(project['iatiId']) || '' %> <%if !r4dDocs.nil? && r4dDocs.length > 0 %>

    This project has supported the following research projects and/or publications

    <% r4dDocs.each do |s| %> diff --git a/views/projects/summary.html.erb b/views/projects/summary.html.erb index 1304f3b4..13e7c59c 100755 --- a/views/projects/summary.html.erb +++ b/views/projects/summary.html.erb @@ -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"} %>
    diff --git a/views/projects/transactions.html.erb b/views/projects/transactions.html.erb index 77c78088..fc7d7bfc 100755 --- a/views/projects/transactions.html.erb +++ b/views/projects/transactions.html.erb @@ -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 %>